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.
The script as submitted here works, but too quickly. Apparently, PureFTPdMgr creates an invisible file in the target folder the moment an FTP upload is initiated; it begins with a period (.) and is in the form “pureftpd-upload.4af47b30.15.36b.f72d8d10” The creation of this file immediately triggers the Folder Action Script, and the email that’s generated and sent ONLY lists the “.pureft-upload” file. Then, subsequently, the real file (“example.pdf,” for instance) that the customer was uploading, ALSO gets listed in a SECOND email message, but one that unfortunately doesn’t have a “To” Recipient, and so it just stays open in Mail on the FTP Mac, while the first email gets sent.
Any help would be appreciated. I don’t know applescript at all (most of the coding I’m attaching was taken from someone else’s script on this site), so I don’t know how to tell it, for instance, to ignore certain file names or to wait until all files have been uploaded, or whatnot. Thanks!
property theName : "myname"
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, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ", "}
set added_Items_List to added_Items_List as text
set AppleScript's 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
Model: G5 dual 2.3GHz
AppleScript: 2.2.1
Browser: Firefox 3.5.5
Operating System: Mac OS X (10.5)