Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

buddyjack2

macrumors newbie
Original poster
Mar 4, 2008
3
0
I'm trying to create a script that I can attach as a Folder Action to each of about 50 folders accessed by our customers when uploading files to us via FTP. The idea is for me to be sent an automatic email alert by our FTP Mac (located in a separate office) whenever anyone uploads files into it. It's running OS X 10.5.8. On it, I used PureFTPdMgr to designate each of our customers as a "virtual user" each with their own folder that they automatically access when logging in over FTP their user name and password.

But the script, below, only works when I drag-n'-drop files into these folders myself either over our LAN or at the FTP Mac itself; for some reason, FTP uploads don't trigger the Folder Action. I read some old threads saying a folder window has to be open in order for the adding-files trigger to kick in, but I think that may be an obsolete requirement? Thanks for any help, the script is as follows:

property theName : "My Name"
property theAddress : "myname@mycompany.com"

on adding folder items to this_folder after receiving added_items
set added_Items_List to {}
repeat with oneItem in added_items
set end of added_Items_List to name of (info for oneItem)
end repeat
set {TID, text item delimiters} to {text item delimiters, ", "}
set added_Items_List to added_Items_List as text
set text item delimiters to TID
set dateString to (current date) as string
set theBody to "Items including the following have been sent via FTP by our customer " & name of (info for this_folder) & ":" & return & return & added_Items_List
tell application "Mail"
set newMessage to make new outgoing message with properties {visible:true, subject:"FTP Site Alert: " & dateString, content:theBody}
tell newMessage
make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
end tell
activate
send newMessage
end tell
end adding folder items to
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.