I'm using a folder action to create a "hot" folder, which immediately duplicates the files placed in this folder to a specific backup folder.
This is the script I'm using as folder action and it works fine:
on adding folder items to this_folder after receiving these_items
tell application "Finder" to duplicate these_items to folder
("Macintosh HD:Users:photograper:Desktop:Target:")
end adding folder items to
But I want to run this folder action like a normal applescript and trigger the "adding folder items" function with a "Choose folder" command. So I can manually point a specific source and target folder and get the script running.
I tried this, but no result:
set this_folder to choose folder with prompt "Select source folder:"
with multiple selections allowed
set target_folder to choose folder with prompt "Select backup folder:"
on adding folder items to this_folder after receiving these_items
tell application "Finder" to duplicate these_items to target_folder
end adding folder items to
Any suggestions how to combine the two parts of scripting together so they can interact?
Thanks!
Patrick
Best Answer
Just remove the handler and change the variable "these_items" for "this_folder", like so:
Then run the script as a normal script, and it will copy the folder entirely to your destination.
If, on the other hand, you just want the items to be copied (not the folder), you could use this variation:
Either way, you would end up with a duplicate of the contents of the folder.
Now, given your comments below, this version will run the script as a folder action, but will remember your destination folder when you declare a property at the beginning of the script. If you recompile the script, it will ask you again.
I hope this helps.