Copy files dropped in a folder to other folders

I have been away from Applescripting for a while working with and learning another scripting language. And I have not really ever done much with folder actions (worked mostly with scripting QuarkXPress). I am wondering how to go about setting up a script that will copy a file when dropped in a folder to three or four other folders on a server. Is it even possible?

Well I tried this script and it worked fine when I specify the file name. And of course this is just on my HD from one folder to another.

tell application “Finder”
duplicate file “Mac OS X:Users:sld:Desktop:04-07-00 SD Time.pdf” to folder “Mac OS X:Users:sld:Documents:FOLDERS:Current Items:xMOVE TO:Folder 1:”
end tell

Then I tried this dropplet script and nothing.

on open
tell application “Finder”
duplicate every item of selection to folder “Mac OS X:Users:sld:Documents:FOLDERS:Current Items:xMOVE TO:Folder 1:”
end tell
end open

What am I doing wrong? Anyone.

Your script doesn’t work because you’re relying on the selection.

If you think about it, even if you select the relevant items before invoking the script, you then double-click on the script icon which changes the selection.

Using ‘selection’ is inherently dangerous, just for that reason.

Instead, be more specific in what you want to do:

on run
   tell application "Finder"
      duplicate every file of folder "source folder name" to folder "Mac OS X:Users:sld:Documents:FOLDERS:Current Items:xMOVE TO:Folder 1:" 
   end tell
end run

Alternatively, if you’re setting up a drop-box environment, consider using Folder Actions to perform this as soon as any file is dropped in the source folder:

 on adding items to this_folder after receiving these_files
   tell application "Finder"
      duplicate these_files to folder "Mac OS X:Users:sld:Documents:FOLDERS:Current Items:xMOVE TO:Folder 1:" 
   end tell
end adding items to

Then use Script Menu to add this script as a folder action script on the relevant folder.

Thanks very much. I used the second example of a folder action because it seemed the easiest to understand. It works very well. I just had to add the word folder before the word items to get it to work.

I actually have three folders a server volume that I need to copy files to when ever I get them finished and I got tired of copying and pasting them in three seperate places. One of the locations changes with each month and so I added a choose folder with prompt dialog so I only have to navigate to one folder instead of three.

I need to work at getting it so I can do the same with a dropplet. Thanks for the help.

I recently posted trying to create a “DropBox” that would activate when a file was placed there and prompt with some drop-down menus for the path of where to put the file.
Here’s my post, along with my final code.

http://bbs.applescript.net/viewtopic.php?p=32175#32175

I’m pretty sure you could modify this to do what you’re wanting and more. I used AppleScript Studio, and a basic NIB.

Thanks very much. I will take a look at this closer.