I’m looking to create an Automator service containing the following Applescript (or an Applescript that will act the same way). The service will work on Finder items, single or multiple files and/or folders. First, I select items in the Finder, then go to the Services menu to invoke. When invoked it will do the following:
A popup will ask me to select move or copy
A second popup that will ask me to select a destination from a list of destinations.
The selected files and/or folders will be moved to the selected destination.
set theMethod to button returned of (display dialog "Select Move or Copy" buttons {"Move", "Copy"})
set the_list to {"Desktop", "Documents", "/Ext HD/Photos"}
choose from list the_list
set theDestination to result
if theDestination is false then return
display dialog (theMethod & " to " & theDestination)
if theMethod is equal to "Copy" then
tell application "Finder" to duplicate items to folder theDestination with replacing
else if theMethod is equal to "Move" then
tell application "Finder" to move items to folder theDestination with replacing
end if
to move or duplicate items with the Finder you have to specify the full path to the destination folder.
“Desktop” and “Documents” are common folders and can be specified with predefined relative paths.
Other (custom) destinations must be HFS paths (starting with a disk name and separated by colons).
Copy the script in an AppleScript action in Automator.
property destinationList : {"Desktop", "Documents", "Ext HD:Photos:"}
on run {input, parameters}
try
set theMethod to button returned of (display dialog "Select Move or Copy" buttons {"Cancel", "Move", "Copy"})
on error
return input
end try
set theDestination to choose from list destinationList
if theDestination is false then return input
set theDestination to item 1 of theDestination
try
if theDestination is "Desktop" then
set theDestination to path to desktop
else if theDestination is "Documents" then
set theDestination to path to documents folder
else
set theDestination to theDestination as alias
end if
if theMethod is "Copy" then
tell application "Finder" to duplicate input to theDestination with replacing
else if theMethod is "Move" then
tell application "Finder" to move input to theDestination with replacing
end if
on error e
display dialog "An error occurred: " & e
end try
return input
end run