Productivity...Tomorrow

Using Automator to Handle Receipts

Recently my Wife and I attended the 2016 Macstock Conference & Expo. It’s a wonderful event where each year we get to meet new people with common interests and learn amazing things about our Macs.

One of my favorite presentations this year was from engineer Kirschen Seah about Automator, the fairly easy to use “Swiss Army Knife” built-in to every Mac. Not only did Kirschen do a presentation on Automator, later in the day she also led a “deep dive” session into the same topic. I followed right along to learn what I could during the class. I had heard about Automator, and being a programmer and productivity geek, I’m sure I had opened it before, but until now I had not used it to create any helpful workflows.

The best way for me to learn a new topic is to dive in and use it on something relative to me. Browsing around at the actions available in Automator, it looked like the perfect way to get my monthly company expense receipts organized and prepared for submission.

The Problem To Be Solved

Each month I need to submit to our HR department any receipts I need to be reimbursed for. Many of these receipts are created on my Mac from online web orders. Up until now, I would save a PDF of the receipt to my downloads folder, then open Evernote and drag it in. At the end of the month, I would either print them all off one by one to hand in, or I would have to copy them up to our company’s server that has Acrobat installed and use Acrobat’s “Combine PDF” feature to combine them into one document I could email to HR in case I’m on the road.

Both of these tasks were very annoying and I knew there had to be a better way, I just didn’t know what way that was until Kirschen demonstrated just how many things Automator can do!

Web Receipts & Dropbox

As I started to figure out what would be the best workflow to get these receipts organized, I immediately found an option in Safari I’d not noticed before. When printing a document from the web and clicking the down-arrow next to the PDF option, I saw “Save PDF to Web Receipts Folder”.

Screenshot of Save PDF to Web Receipts Folder

Upon further research, I learned this was just a folder called “Web Receipts” created in Documents upon first use that would store all receipt PDFs you saved here. This looked like a great place to keep them all, but I really wanted this folder in Dropbox so I could access this folder from multiple devices and eventually save receipts from my iPhone as well.

To fix this, I used the code below to move my Web Receipts folder to Dropbox and created a “symbolic link” to it in Documents. This essentially “tricks” the Mac into thinking the Web Receipts folder is in the same place, even though I moved it to Dropbox. Please Note: This is completely optional and is not necessary if you are perfectly fine with the default home of the Web Receipts folder.

cd ~/Documents
mv Web\ Receipts ~/Dropbox/BobzStuff/Web\ Receipts
ln -s ~/Dropbox/BobzStuff/Web\ Receipts Web\ Receipts

With Web Receipts now stored in the cloud, I could easily save receipt PDFs to this folder throughout the month. Now, I just needed an easy way to combine them all into one file for easy printing or emailing.

Adding In Automator

Here is where Automator goes into action. I created an “Application” Automator workflow called “Combine Receipts” right inside the Web Receipts folder. It consists of the following actions.

  1. Get Specified Finder Items - I pointed this action to my Web Receipts folder in Dropbox so Automator knew what folder I wanted to work with.
  2. Get Folder Contents - This retrieves a listing of all the files in the Web Receipts folder.
  3. Filter Finder Items - Here I only want to select PDFs as well as exclude any previous month’s combined receipt files.
  4. Sort Finder Items - Of course I’d like them in order, so I sorted them by the creation date in ascending order.
  5. Combine PDF Pages - This is where a lot of the magic happens, combining each PDF into a single document. The file is then stored in a temporary directory with a random name.
  6. Rename Finder Items: Name Single Item - Here I name the file what I really want to call it, “This Month’s Receipts.pdf”
  7. Move Finder Items - Finally, I move my renamed file back to the Web Receipts folder, replacing any previously combined PDF.

Screenshot of my Automator workflow

So now, at the end of the month, I can easily just double click on “Combine Receipts.app” and it will work it’s magic saving the combined receipts right in the same folder for me to turn in.

Wrapping It Up

So with just a few fairly simple drag and drop items, I’ve created a really powerful workflow. I know there are lots of ways to solve a problem like this, but with Apple’s Automator being baked into every Mac, everyone should at least give it a try to solve a problem they might have. Just open up Automator and play around. Experimentation is the one of the best ways to learn more about an application.

As a developer, figuring out solutions like this is exactly what we do. For those that aren’t developers and have never programmed a single line a code, Automator is a great way to “test the waters”. Using the same skills to work through the problem, you too can feel the gratification that comes once your masterpiece is complete and it works exactly like you planned.

I would like to thank Kirschen Seah for her great presentation at Macstock. I’m definitely putting the information I learned to good use! Macstock 2017 is already in the works, so if you’d like to learn some cool new tricks and meet some awesome folks, visit macstockconferenceandexpo.com and follow @macstockexpo for more info!

Photo of Bob Butterworth

Hello, I'm Bobby; a web developer, designer and serial procrastinator from the suburbs of Chicago, IL.

Topics

Subscribe