Please kindly let me know how to make the macro for below.
I want to open(popup such as quicklook) specified file like a txt or jpg for instant reference.
I don't want to open with it by text editor or photo viewer, want to see it by quicklook.
Thank you for your response.
I've tried it but I'm really beginner.
So I couldn't find how to designate a file.
I would appreciate if you could let me know how.
tell application "Finder"
set pathFile to selection as text
set pathFile to get POSIX path of pathFile
do shell script "qlmanage -p \"" & pathFile & "\""
end tell
Here it is in less simple form with more canonical AppleScript and basic error-checking.
-Chris
try
tell application "Finder" to set finderSelectionList to selection as alias list
if length of finderSelectionList ≠ 1 then
error "Problem with number of files selected in Finder!"
else
set filePath to get POSIX path of item 1 of finderSelectionList
set shCMD to "qlmanage -p " & quoted form of filePath
do shell script shCMD
end if
on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
try
tell application (path to frontmost application as text) to set ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try
I'm trying to stick a long filepath that includes spaced text strings into "qlmanage -p" to make it do a quicklook preview of the document at the path. First, I get the filepath into a variable. In an AppleScript, I tell Finder to get POSIX path of the filepath in the variable and make a new variable with the POSIX path. I then tell Keyboard Maestro Engine to grab the "quoted form" of the POSIX path and put it in a KM variable for export back into KM. I then stick the KM variable with the quoted form of the POSIX path into the shell script, i.e., qlmanage -p %quickPath%. Throws error. What am I missing? Do I need to encode the filepath to deal with the spaces?
Thank you. When I stick the %variable% in the Execute Shell Script action, it throws error "no job control" but when I write out qlmanage -p "/Path/To/File.txt", it works and shows me the preview. I can't get the shell script action to unpack the variable.