I am trying to make a droplet that will scp the files to a fixed location. My plan is to use ‘do shell script’ for the scp command. I need to be able to insert the path to the file I am copying.
How can I get the path to the file that was dropped on the droplet?
on open someFiles
someFiles
--> {alias "path:to:file", alias "path:to:folder:", alias "path:to:folder:subfolder:file"}
end open
When you drop some stuff onto your droplet, a list of aliases is passed to the “open” handler. Then you can do whatever you need. Eg:
on open someFiles
repeat with i in someFiles
mySCP(i)
end repeat
end open
to mySCP(i)
do shell script "cp -f " & quoted form of posix path of i & " /tmp/"
end
That was simple enough. Works great.
Where can I find more info on “POSIX form”?
Hmmmm… I don’t think there is more info. These are the only possibilities (see “StandardAdditions” dictionary):
POSIX path of alias "diskName:" --> "/"
POSIX path of "diskName:" --> "/"
"/" as POSIX file --> file "diskName:"
POSIX file "/" --> file "diskName:"
And quoted form will work for any string. Basically, it works as you see, usually used to pass strings to the shell, to avoid blank spaces or not-compatible characters:
quoted form of "wha tev er" -- "'wha tev er'"