I am very new to AppleScript. I frequently share files from my local computer to Dropbox folder.
From: ~/Work/hello.txt To: ~/Dropbox/zzz_ShareMe/hello.txt cp ~/Work/hello.txt ~/Dropbox/zzz_ShareMe/ # or, just copy files from finder
I googled about AppleScript and came up with a workflow that copies ONLY ONE Item, But how can we select multiple files and copy them to Dropbox with an assigned hotkey (ctrl-alt-d)?
The contents of Run NSAppleScript is given below:
# Note: we should have ~/Dropbox/zzz_ShareMe folder # on alfred_script(q) tell application "Finder" set source to (POSIX path of (the selection as alias)) do shell script "cp -r" & space & quoted form of POSIX path of source & space & "~/Dropbox/zzz_ShareMe" end tell end alfred_script
I have shared my preliminary workflow here.
This workflow works for a single file.
If I select a file in Finder, ctrl-alt-d copies the file to
~/Dropbox/zzz_ShareMe/, however, If I selected multiple files and used that hotkeys nothing is copied.
How can we fix that problem.
Help will be appreciated.
Update I tried another script, but it still fails.
- select multiple files in Finder
- it should copy all files to
The new script is given below:
on alfred_script(q) tell application "Finder" set source to selection end tell if (count of source) is greater than 1 then set fileList to every item of source repeat with source in fileList doMove(source, q) end repeat else doMove(source, q) end if end alfred_script on doMove(source, destination) set source to (POSIX path of (the source as alias)) set destination to "~/Dropbox/zzz_ShareMe" do shell script "cp -r" & space & quoted form of POSIX path of source & space & POSIX path of destination end doMove