Apple Event: May 7th at 7 am PT

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

Automator Folder Actions - Use filename as subject in email

I regularly email .pdf atttachments to my head office. These are hand-written sales orders which are scanned in. The scanner software gives each file a sequential filename (eg. OrderNo_110612).


I have set up a Folder Action in Automator to create a new email and send the file as an attachment when it is added to the folder.


Get Selected Finder Items

New Mail Message

Send Outgoing Messages


I would really like to add the filename to the subject of the email. Is there a script I can run within the 'Run Shell Script' action that will extract the filename and can then be used as a variable in the subject field? This would allow both myself and head office to easily find the email at a later date should the need arise.


Any help would be gratefully received. I am not a programmer, although I understand the principle of variables etc..


I am using OS X Lion 10.7.2


Any help would be really gratefully received.


Many thanks

iMac, Mac OS X (10.7.2)

Posted on Nov 15, 2011 11:17 AM

Reply
Question marked as Best reply

Posted on Nov 15, 2011 1:07 PM

to do this you want to use a variable. It's a little tricky, but not too bad. basically do the following. First set up a couple of variables (call them filePath and fileName). then add these actions:


  1. get selected finder items - this passes a list of file references.
  2. set value of variable - filePath - this saves the file references in a variable, and passes them on
  3. run applescript - use the applescript below to get the file name and pass it on
  4. set value of variable - fileName - this saves the file name in a second variable
  5. get value of variable - filePath - recover the file reference variable and pass it on. make sure this action does not receive input
  6. new mail message - makes a new mail message with the appropriate attachment. add the fileName variable to the subject line by dragging it from the variable list.
19 replies

Mar 31, 2014 4:38 PM in response to j. patrick

I use Deliver Express to do this. I also use Hazel.


I save my report pdf to a specific folder

Hazel renames the file by adding the date on the end and then moves it to a "Hot Folder"

I give Hazel a rule that says the pdf has to be older than 5 minutes to give myself time to make changes if I need.


The "Hot Folder" is any folder I have asked Deliver Express to "watch"


Deliver Express moves the pdf to a Dropbox folder that I have shared with the person getting the report. It then sends a email to that person with the pdf name as the subject and the body of the email is "There is a new "name of report" available for viewing in Dropbox."


Deliver Express can send the pdf within the email but some of my reports are too big to email and are viewed by a few people in the shared Dropbox folder.

Automator Folder Actions - Use filename as subject in email

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