Murphy Mac - Screencasts and Tutorials » Page 'Files Mailed Magically When Dropped in a Finder Folder'

Files Mailed Magically When Dropped in a Finder Folder


Murphy MacThere must be someone you email stuff to all the time. Maybe you send your mom pictures. Or you send an agenda to your boss every day. That can take a lot of clicks. Open Mail. Create a message. Address it. Attach the file. Write a subject. Sounds like a lot of work.

Instead, watch this Snippet. You can create an action that grabs every file you add to a folder and mails it off to a pre-configured address. Click to see an example. Or click Watch Now below to see how to set it up.

Murphy uses this as a crude backup tool. He drops key files to a folder and they are instantly whisked away to a free email service. Quick and convenient archiving.

What do you think? Too lazy?

Bonus: Murphy has provided a Folder Action script that prompts for a subject before sending the attachment.

Download Script

or Download Script w/ Subject Prompt

Update, June 2007: See this new post on this subject.

Watch Now | Permalink

55 comments to “Files Mailed Magically When Dropped in a Finder Folder”

  1. Thanks for another useful snippet. Anything on Applescript is really useful for me, its part of my Mac arsenal that I have never dedicated enough time to getting to grips with, but it always proves really useful when I do…

  2. This was a great tutorial. I set up four folders for people I most send files to. It works great! I am a relative newbie to OS X. Tricks like this show how powerful OS X is right out of the box. Is it possible to have the file automatically deleted from the “mailer folder” after it is mailed?

  3. Good idea but I don’t understand the point of using a folder action. Why not compiling the script as a drop box? It would be easier to set up (no messing around with the folder actions) and also the file to be sent will stay were it is instead of going inside the folder.

  4. Now..if i could just get this script to stop sending .DS_store files as well.

  5. I wanted to use something like this to use my gmail account as a backup and net accessible storage. But along with automatically sending the email, I wanted to have the filename of the document automatically be the subject of the email so that my new archive could be easily searched. Also, like Olivier, I wanted an icon to drop things on, not a folder. Here’s Murphy’s script with those changes made (in the script editor you would save it as an app, otherwise use is the same as in the snippet):

    on open files_

    repeat with eachitem in files_

    set theSender to “”
    set recipCommon to “”
    set recipAddress to “”
    set msgText to “”
    set iteminfo to info for eachitem
    set theSubject to name of iteminfo

    tell application “Mail”

    set newmessage to make new outgoing message with properties {content:msgText & return}
    tell newmessage
    set visible to true
    set sender to theSender
    set subject to theSubject

    make new to recipient with properties {name:recipCommon, address:recipAddress}
    make new attachment with properties {file name:eachitem} at after the last paragraph

    end tell
    send newmessage
    end tell

    end repeat

    end open

  6. Excellent. Thanks Chris.

    I must say the TUAW thing caught me off guard, I haven’t messed much with droplets. More material for future snippets!

  7. Thank you Murphy and Chris Holden, this thing is extremely useful for me.

    Can anyone point me somplace I can learn to write this code? Right now it can’t seem to handle more than one file being dropped on it at a time and I’d like to try to fix that.

    But thanks again,


  8. I don’t have a set person I send things to all the time, but I really love the drag and drop feature of taking a file and dropping it on top of the Mail icon to open/new/attach. It’s a good thing.

  9. I cant seem to set up my mail account. whenever I get to the general information part of the mail setup i cant seem to get it right with the info. can u guide me through it. Thanks abunch murph

  10. Do you have any idea murph?

  11. Malvern –

    Try these instructions.

  12. Is there any way to ammend this script to email a list of files that has been added to a folder instead of actually sending the file? I would like to be able to add files to a certain folder and then have someone receive an email (perhaps a sort of daily digest) that tells them exactly what files have been added so that they can then browse to the folder and see the files at their own leisure. Some of the files are large video files, hence the reason I don’t want to email them direct.


  13. I would set up the folder to run a shell script. Your shell script could run something like this:

    find . -cmin -10 | xargs basename>newfiles.txt
    That would give you a text file called newfiles.txt listing files in the current directory changed in the last 10 minutes. Adjust the 10 for whatever you need.

    Then use cp or mv in a shell script to move the newfiles.txt file to a folder set up like this post – which will mail the file. You could get fancier and append some other text with the cat command.

    I have a post about creating shell scripts. You should look at the other Terminal screencasts too. The cat command is mentioned in a few of them.

    You’ll probably need to kick off your shell script from an AppleScript. Checkout Do Shell Script for that.

    I’m not sure I’d do the whole thing as a folder actions – at least not with the way my script works.  My script sends every file added to the folder in a separate email.  I don’t think you want a notification email going out for EACH file you add to the folder.

    Instead, you could have the script run once a day or every hour or whatever – and it would see what was new and send an email with the list of new files inside it.

  14. Thanks for your suggestions Murphy – that was extremely helpful of you. Having thought about it a little bit more tho, I think I have decided to create a droplet which I can drop the files I want on the network drive onto and then have it automatically copy the files to the correct location on the network drive and also create and mail a list of files that have been dropped onto it. That has the benefit of not needing to set up a cron job and not using sytem resources (however negligible) when it is running on schedule. If I actually manage to get a script working, I’ll post it over to you.

  15. Thank you so much for your great tutorial murph. I have a limited knowledge of this area but found your instructions extremely easy to follow. However is there anyway to have a dialog box pop up which asks you: to stick with the default text entry for the body OR to type a unique one for this particular email?? As in: “Body of message…” and below an area to type and below that with two buttons: ‘accept’ or ‘revert to default’.

    Is this possible? If not, then just a place to type the body of the email with no default text to revert to.

    Cheers for a super website


  16. I’ve just submitted a new version of this tutorial to a contest and can direct you to the entry this week. The new version covers two ways to make this work – one with AppleScript and one with Automator. The Automator one makes it pretty easy to do what you want.

  17. This is exactly what I expected to find out after reading the title es Mailed Magically When Dropped in a Finder Folder – Murphy Mac. Thanks for informative article

  18. Love the script, but I would also like to mail the file names only. as I have a ftp server that would need to send to separate people with newly received files.

  19. Never mind, I got it. set iteminfo for eachitem and msgText to iteminfo.

  20. Sweet! script,

    The files i’m emailing are text how would i get it to display in the body instead of them being attached.

  21. Excellent Work murphy!! A few quick queries though…

    1. Is it possible just like the subject prompt, a prompt for thee recipient address is alos there. What I mean is everytime I am asked to enter not only the subject but the email address I want to send it to???

    2. More importantly can this script be made to run of the Thunderbird application??

  22. Hi! Looks like fun, but it’s not working for me: the file sits in the folder and nothing happens: the file sits in the folder, the finder blinks once as if something is supposed to happen, but nothing appears in Mail’s OUT or SEND boxes. I’m running Leopard: has anybody checked it out on this new os? Or maybe I need to be a big bog and learn how to troubleshoot apple scripts?

  23. Bruce, I got exactly the same result as you. Maybe it is a Leopard issue?

  24. I’ll try it out tomorrow. I just installed Leopard tonight.

  25. I only messed with this for a few minutes, but I don’t see any Folder Actions working. I tried using the ones that come with the OS, like add- new item alert.scpt and that didn’t run when I added something to the folder. So – something might be going on here that has nothing to do with this particular script.

  26. Awesome!!!!!! How do I tweak it so that it asks me the recipients address every time I send an email. That is how do I make it prompt me for an address as well??

  27. Check out the newer version of this screencast. It shows how to make an automator action that does just what you want…

    Let me know if you have trouble.

  28. Hi,
    Thanks…….i am new to apple script..i need to know hoe to set the folder…moreover i need to just watch the folder in my server and not through any mail…please help me..

  29. Hi,
    Thanks very much………it is working great……

  30. If you’re having trouble getting folder action scripts to work in Leopard check the permissions. Make sure they’re like the permissions on the built in script files. I had trouble getting this working until I duplicated an existing script file and pasted in the script text.

  31. Hi,
    Ur watch folder is working fine.I need apple script to run this watch folder for 4 or 5 folders using apple script……..

  32. How can I use the mailer script on a network folder so everyone on my network can benefit from it?

  33. how can i make it stop sending .ds files.

    also any way i can change the script so that file name/names will be automatically used as subject line.
    I tried to use chris holden’s script. But it is causing syntax errors.
    BTW, i use leopard.

    Thanks for all the help

  34. Great script. I am looking for something like that. I would like to sync my folder with a FTP server using SFTP. Is it possible to do that. If you can you help me on that.


  35. hi i love your script, but I use entourage (on leopard). i tried simply swapping the tell application “mail” command with “microsoft entourage”.

    Then when i tried to save the script it kept reporting that there is a syntax error, in the line: “make new attachment with properties {file name:eachitem} at after the last paragraph” – the word “name” is highlighted and the error message says: “Expected “:”, etc. but found property.” So then I joined fiddled with the word “name” deleting it, deleting the space between it and file, and the result is that when i enable the folder action and drag a file into it, i find a new email in my entourage drafts folder, which has the correct sender, recipient, subject and text, but no file attached, and it is not sent. any suggestions?


  36. Wow – I wouldn’t have expected that you’d get that far that easily!

    You need to look in the Applescript Dictionary to see what commands it uses with Entourage. If you don’t get anywhere I’ll post something on the site seeing if anyone can help you, as it would probably help many people.

    When your script editor is open click on File >> Open Dictionary and then look or Microsoft Entourage in the list.

    Actually – according to this thread it looks a lot like it would with Mail. Let me know if you get it working – or if you’re stuck.

  37. Hey Murphy,

    I’ve been trying out your script on a Leopard machine but getting some fairly erratic results. I tried your permissions thing from above but that hasn’t helped.

    It seems there is a maximum of 7 emails with file attachments that will automatically get sent with the 8th always stopping just before inputting the recipient name.

    Notably, when I use another script to move files from several other locaitons into my “Send Mail” folder to which this script is attached, it does exactly the same same thing but this time on the 1st message.

    Just wondering if you knew of any conflicts or limitations that might be causing this.

  38. Thanks for the script, is there any way to avoid having the .DS file emailed? It seems that once more than one file is in the folder, it creates an invisible .DS file. Is there a way to edit the script to only recognize visible files? Or is there another way to avoid sending the .DS files?

  39. I tried couple of time, recheck and recheck..but its didnt work..there was nothing happened…

  40. How can I make the subject “[fax] ” plus the name of the file being dropped into the folder? Thanks.

  41. Murphy, your my hero! This is so useful, I can’t thank you enough. I am a freelance designer, who on any given day, creates anywhere from 10 to 30 ads that I must then save as a PDF and email to a handful of clients that I work with on a regular basis. I already have watched folders for each client set up in distiller. Now, rather than emailing all the proofs I’ve worked on to each client at the end of the day or stopping my work flow to email each proof as I do them, they’re sent off as soon as distiller is done creating the PDF. I’ve been wanting something like this for almost 10 years now. I had no idea that scripts could do so much. I am officially an AppleScript fan.

    P.S. the edit for changing the subject to the file name was also very useful. My next question after I set up the folder action and it worked was, “Now how can I make the subject the same as the file name?”. Then I read your post. Thanks Chris.

  42. Dan.

    When I use the scrip you provided the email gets created and sent no problem with the subject being the file name, however, the file does not attach itself.

    Do you know why this would be?

    Also, do you know how to remove the extension from the file name in the subject line?

  43. any idea how to attach this to an Adobe Acrobat Distiller “out” watch folder so every time a PDF file is produced it’s emailed automaticall?

  44. I can’t decide whether I like it or not. I prefer cloud storage even using something like CloudApp (which is what I use now… and constantly) and it’s secure and easy to share if needed. And I can decide whether I think this method is more organized or not. I’ll try it out and see but I think I’ll stick to cloud-based storage in the end. Thanks man!

  45. Hi, I’m realtively new to AppleScript but this tutorial is GREAT….I’m almost all the way there…..

    I’m trying to figure out how to add the NAME of the file that was dropped into the folder to the email that I’m sending….I don’t want to attach the actual file, just the name of the file….

    Is that possible?

    Thank you.

  46. Love the script, and it has helped a lot. One problem. I drop PDF files in the folder to be sent to an email address. Often enough, I need to make changes to one of those files, and resend a revised PDF. If I drop a PDF of the same name in the folder, it tells me there is already a file of the same name, and asks if I want to replace it. When I click “replace it” the new revised PDF is in the folder, but it does not get sent in an email.

    Is there anyway to modify the script so revised files of the same name can replace older files and still be sent?

  47. A good idea. Maybe modify the script to copy files that have been mailed to a subfolder and keep the top level folder clean?

  48. Murphy this is awesome. I was wondering if this is possible. I would like to back up photos to my unlimited yahoo mail. Is there a way to drop a ton of photos to a folder and have the script send the files but each email doesn’t exceed 20mb. Either with a script or automator. Thanks

  49. hi murphy

    Is it possible to develop a the same programme to windows??

    look forward you repply.


  50. Good Article!

  51. For example, a piece of Internet marketing strategies won t find
    iit and I’ll get all the sitges are all the HTML specification. These will not provide anny kind of traffic flavored balsamic vinegar ffor process
    improvement. We usee tried, tested and highly
    appealing. So if you are not on thhe most fruitful results to improve Google+ results?

  52. Eat we olive while the other hand, have the black rice bran. There’s four quarter-pound burger patties, Sesame Seeds and CashewsMakes
    4 servingsPrintable recipe.

  53. Wow, tried this tool and it works like a charm! I have been looking for a while now for a script like this. Combined with a folder action for resizing images this is a great timesaver, who would have thought that Automator and AppleScript are such powerful tools!


    The only thing I had to adjust was the recipient-definitions. In my case I had two mail-addresses where I wanted to send my files to.

    To send the files to two instead of just one recipient I had to create an easy workaround (probably not the most elegant method):

    I added for the 2nd recipient two additional lines of code right after the “set recpiAddress to”-Line:

    set recipCommon2 to “Name”
    set recipAddress2 to “”

    then further below where I copied the “make new to recipient with properties”-line and adjusted it like following:

    make new to recipient with properties {name:recipCommon, address:recipAddress}
    make new to recipient with properties {name:recipCommon2, address:recipAddress2}

    Thanks a lot!

  54. What’s up to all, the contents present at this web
    ssite are truly awesome for people knowledge, well, kesep up the nice
    work fellows.

  55. I’ve been using FinderSender for years successfully, but recently it’s stopped sending attachments – it just sends blank emails with the correct subject, but without the attachment.

    Can anyone suggest what might be going wrong?


Leave a comment