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

Automate a folder to send email with Folder actions

Hi,

I was wondering how I could set up and automated folder to send an email to me when a new file is copied to that folder. Here is the reason why I want it to do this : I just set up a FTP server on my iMac which is at home. I have no idea if someone dropped something on my FTP server unless I check every hour or so. I thought I could set up a folder action to make it send me an email saying there is a new file or whatever.. Is this possible? If so, how can I do this?

Thanks

17" iMac 1.83 Intel Core Duo, Mac OS X (10.5), 2 GB of RAM - SuperDrive

Posted on Feb 12, 2008 8:31 AM

Reply
10 replies

Feb 12, 2008 9:06 AM in response to kpott

Add the following folder action to your folder

-------------------------------------------------

on adding folder items to this_folder after receiving added_items
try

tell application "Mail"
activate

set theMessage to make new outgoing message with properties {account:"Gmail", visible:false, subject:"A new file has been added to folder such and such", content:"Whatever you want to put here"}
tell theMessage
make new to recipient at end of to recipients with properties {name:"recepient's name", address:"recepient e-mail address"}
end tell
send theMessage
end tell
end try
end adding folder items to


---------------------

In the script fill in the recepients name and e-mail address. Also, the script is set to send the e-mail from a Gmail account. Change that to whatever account name you want to send it from. Of course, you can edit the subject and the body of the message in the above.

Feb 12, 2008 11:55 AM in response to scb

that shouldn't bee too hard but I don't use iMovie (my powerbook is too underpowered to handle iMovie 08 and I lost the install disk with iMovie 06). Check out the following link
http://www.macosxhints.com/article.php?story=20041006011654395

You can enter a delay command between the two halves of the script to set the recording time. To activate the script at a certain time you can either use a cronjob or a launch daemon (that's how I do it). the easiest way to schedule a cronjob if you don't want to muck around with system files is by using Cronnix (it's a GUI front for cron). Here is the download link.
http://h775982.serverkompetenz.net:9080/abstracture_public/projects-en/cronnix/d ownload/

Feb 12, 2008 12:41 PM in response to V.K.

Warning: the script link I mentioned in my previous post is old and was made with an older version of iMovie in mind. It might need tweaking. Unfortunately, iMovie is not scriptable (a bit surprising for an Apple app). This means that the script will have to be rather inelegant and use various "click button" commands. i definitely can not write a script like that without a working copy of iMovie. I can test it next week when I get to the Mac pro in my office but until then you are on your own.

Feb 12, 2008 3:37 PM in response to V.K.

Thanks so much. I have a PB G4, but hacked iMovie 08 to work on it. It runs well. I am at foolyou@mac.com, if you think of me. I really have no clue how to script. I will mess with the links, but I really am helpless. Thanks so much.

Note: Sorry about stealing this thread.

Feb 14, 2008 11:24 AM in response to V.K.

I can't seem to make it work. I tried opening "script Editor" compiled my script, saved it in the FTP folder. Enabled Folder Actions. Attached the script I compiled to that Folder. Still won't send an email. Should I see Mail make a new message and send it? Should I at least see the mail sent in my Sent mailbox?

Here is my script :
on adding folder items to this_folder after receiving added_items
try

tell application "Mail"
activate

set theMessage to make new outgoing message with properties {account:"cinetic", visible:false, subject:"Un nouveau fichier a été déposé sur votre site FTP.", content:"Un nouveau fichier a été déposé sur votre site FTP, S.V.P. vérifier le contenu dans les plus brefs délais.

Merci!
"}
tell theMessage
make new to recipient at end of to recipients with properties {name:"Kevin Pott", address:"kevinpott@cinetic.ca"}
end tell
send theMessage
end tell
end try
end adding folder items to

Feb 14, 2008 1:01 PM in response to kpott

hmm, very strange. Let's make the message visible. Also, i gave you a slightly wrong format for the sender account but it should have worked any way (it did for me). Yes, you should definitely see Mail make a new message and send it.
Try the following script. I tested it and it works on my computer.

-------------------------
on adding folder items to this_folder after receiving added_items
try

tell application "Mail"
activate

set theMessage to make new outgoing message with properties {sender:"kevinpott@cinetic.ca", visible:true, subject:"Un nouveau fichier a été déposé sur votre site FTP.", content:"Un nouveau fichier a été déposé sur votre site FTP, S.V.P. vérifier le contenu dans les plus brefs délais.

Merci!
"}
tell theMessage
make new to recipient at end of to recipients with properties {name:"Kevin Pott", address:"kevinpott@cinetic.ca"}
end tell
delay 3
send theMessage
end tell
end try
end adding folder items to

-----------

Once the script starts working you should see Mail come to the front, create a new message window, fill in the info, wait for 3 seconds and send it.

You can also test it from the script editor. Just remove the first and the last lines and paste it into the script editor. Then press the "run" button in the toolbar. what happens? I just tested it and it sent an e-mail to you from me so don't freak out if you see it!

Feb 15, 2008 12:02 PM in response to scb

Hi, I finally got to my office but I can don't have any input video devices and I can't write the script without it. However, do you HAVE to use iMovie? Will QT player work? QT player pro can record movies and is scriptable (unlike iMovie) so i can more or less tell you what the script should be without actually testing it.

If you are willing to use QT player pro then I think the following script should work. In this example it will record for 600 seconds (10 minutes). You can adjust that as needed. You can choose a directory for saving recorded movies in the QT player preferences and the file should save there after the recording is finished.

tell application "QuickTime Player"
activate
new movie recording
start first recording
delay 600
stop first recording

end tell

Save this script and launch it at a specific time of day using Cronnix (see my other post in this thread).

Automate a folder to send email with Folder actions

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