Talk about recursive…
background:
My company has an online store. My department works on the web end of the store. Each week new products come in, photos are taken, cleaned up and then posted to the store web site. Part of the production process involves me assigning who does what. I wrote an AS to help manage this process, it automates selecting who is going to work on the next item, creates the various storage folders writes a record to our production database (MySQL) and then jets off an email to the entire production staff (photographers, project managers, designers) letting them know the storage folders are ready and who is doing what.
production happens. sometimes things are fast and furious, sometimes slow and boring. In either instance the designers need to know when files are being dumped into the storage folders and available to be worked on. I want to add a segment to my existing AppleScript which will attach a folder action to these storage folders that would then send an email to the individual designer letting them know product images are ready to be worked on.
OK, attaching the folder action through a script is easy, you can do that with System Events.
I’m assuming, because I want this to be dynamic (different mail recipients, different content) that I have to write a new script each time to attach to the folder. I can get Script Editor to write the script but it doesn’t seem to want to save it.
set FAPath to "Macintosh HD:Library:Scripts:Folder Actions Scripts:"
if not (exists FAPath) then
display dialog "WTF"
else
tell application "Script Editor"
make new document
tell front document
set contents to "on adding folder items to this_folder after receiving these_items" & return & "display dialog \"Items added\"" & return & "end adding folder items to"
compile
try
save as script in FAPath
on error errMsg
display dialog errMsg
end try
end tell
end tell
end if
As a follow-up to this question - if this is feasible and I attach a script to mail folks when their products are available will that mail be generated from me or is there a way with AS to do this through the mail server. I don’t really care, I’ll just write the script to create the mail, send it and then delete the sent message so my mailbox doesn’t get clogged up but it’d be easier (and albeit cooler) if I could do this through the server or something.