Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

New to Folder Actions..Copy new files to network folder

I'm hoping someone can help me. I'm new to the entire OS X environment, and I'm trying to wrap my head around Folder Actions and Applescript. I'm trying to create an action that copies photos that I export from iPhoto to a network folder. Here is the script that I've built, pieced together from things I've searched for over the internets:

on adding folder items to this_folder after receiving added_items
tell application "Finder"
try
duplicate (added_items) to folder "Volumes:Pictures"
end try
end tell
end adding folder items to

The "Volumes:Pictures" is a Windows share. I'm mainly using this to copy photos, but when I test it using any type of file, nothing happens after I paste a file in to the folder. Can someone please point out where I may be going off the rails?

MBP 15" Mid-2009, Mac OS X (10.5.7)

Posted on Jul 21, 2009 2:40 AM

Reply
4 replies

Jul 21, 2009 4:14 PM in response to Creeper74

One troubleshooting method is to run your script in the *Script Editor* without the folder action handler to verify that it runs correctly - the try statement you are using will also trap any errors, so you shouldn't use that untill things are running correctly either. The first error I see in your script is the destination for the duplicate. When using the (colon delimited) Finder path, you need to include the name of the disk, so it should be something like duplicate (added_items) to alias "Macintosh HD:Volumes:Pictures".

Since this is the Automator forum, the workflow to do this would just consist of the Copy Finder Items action - set the destination (To:) to your share, then save the workflow as a folder action plugin.

Jul 22, 2009 1:51 AM in response to Creeper74

I'm no scripting guru and once received help on these forums for a similar folder action. It's attached to ~/Downloads and does the following:
If a file with the extension torrent is added to it, this file gets copied to a file server and trashed afterwards. The script also does the mounting of the share in case it's not mounted. Here it is:

property extension_list : {"torrent"}
on adding folder items to this_folder after receiving added_items
repeat with i from 1 to number of items in added_items
set this_item to item i of added_items
set the item_info to the info for this_item
if (the name extension of the item_info is in the extension_list) then
tell application "Finder"
mount volume "afp://username:password@myserver.domain.or.ip.address/sharedvolume"
delay 1
move this_item to folder "Downloads" of disk "sharedvolume"
delete this_item
end tell
end if
end repeat
end adding folder items to

Maybe this is of help to you. I saved it as an AppleScript and attached it via folder actions.

Björn

New to Folder Actions..Copy new files to network folder

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.