title: Looking to have a folder action that recognizes new files in a folder, then emails the file
body: <p>In macOS, I want a folder action to trigger when I place a new file in that folder. The action should grab the filename, not including the path, and use that as the subject, and then attach the file to an email message and send it. Ideally, this would happen behind the scenes as I don't need to see the activity. </p>
  
  <p>I created an Automator script that can grab the file, extract the name, create and send the file. But it's a bit of a kludge. Once I set a variable to the filename, I lose the attachment and have to get the finder item again. Also, it's not working as a Folder Action which is what I really need. </p>
  
  <p>The Automator includes these steps:</p>
  
  <ul>
  <li>Get Specified Finder Items</li>
  <li>Get Folder Contents</li>
  <li>Filter Finder Items -- I'm only interested in specific files</li>
  <li>Set Value of Variable
  --path</li>
  <li>Run Shell Script -- extract only the filename without the extension
  --basename "$@" .pdf</li>
  <li>Set Value of Variable
  --fileName</li>
  <li>New Mail Message
  --Subject: fileName</li>
  </ul>
  
  <p>At this point I no longer can attach the specified file because Automator has 'lost' it, so I have to start over with the Get Specified Finder Items, Get Folder Contents, Filter Finder Items, Add Attachments to Front Message. Finally, Send Outgoing Messages.</p>
  
  <p>What I want to happen is when I place a certain file into a directory, the Folder Action triggers, it looks at the file, and if it meets the filter criteria it emails the file, using only the filename without the extension as the Subject.</p>