📒 NEW: 2022 Digital Planner: Made for iPad  →  Yes, Please!

A Workflow Using Hazel, Alfred Snippets, and Automator to Rename PDF Documents

I generate a lot of PDF documents every March and April. Some back of the envelope math would clock in around 3,200 documents generated or so. Each tax return would require between 3 and 6 documents, each with their own unique filename. Our naming convention is pretty simple, but requires each client’s name. And each file has to be stored for 7 or more years.

To provide a quick example, I would have to create the following documents for returning clients John and Jane Smith:

  • SMITH, JOHN – T183 – 2021
  • SMITH, JOHN – T1 Client Copy – 2021
  • SMITH, JOHN – T1 eFile Confirmation – 2021

New clients would require at least three more documents, but we won’t get too far into that. The three files above are generated for every tax return we complete.

Each requires a lot of typing as well. Here’s the character count for each filename:

  • SMITH, JOHN – T183 – 2021 (25 characters)
  • SMITH, JOHN – T1 Client Copy – 2021 (35 characters)
  • SMITH, JOHN – T1 eFile Confirmation – 2021 (42 characters)

This seems like an obvious opportunity for automation, right?

I’ve long-looked for ways to automate this process. When working on a Windows PC, I never found a piece of third-party software that could help automate some of this process. Perhaps I didn’t look hard enough. I’m also incapable of building my own script, app, or code to get the job done quickly.

As I alluded to in a recent post, the latest Macs have provided new tools for new professions to get their jobs done in new ways. For me, the M1 Pro MacBook Pro provided an opportunity to consolidate my work and personal computers into one, and dramatically improved my productivity in the process.

One of those improvements is the following workflow, which cuts PDF renaming time by about 80%. Over the course of a tax season, an 80% reduction in PDF renaming could mean $500-$1,000 of billable time, let alone the benefits of perfectly consistent document conventions.

First, Automator Workflows to Rename Files

I’m far from an Automator whiz, but a Google search or two helped me build an Automator workflow that is auto-triggered whenever a specific document name hits my desktop. My “Rename File” works something like this:

  • Ask for Text: This action provides a dialog box where I input the client’s name.
  • Copy to Clipboard: Once I hit enter on “Ask for Text,” the client name is copied to my clipboard. This ensures document 2, 3, and beyond can be a “CMD + V” rather than retyping the client’s name each time.
  • Set Value of Variable: The client’s name is saved as a variable that will be called later.
  • Get Value of Variable: With the variable set with the client’s name, it’s time to grab that variable to apply to the front of a PDF’s file name.
  • Ask for Finder Items: This action provides a Finder window (which starts at the desktop) and allows me to choose the PDF I wish to rename. You can sort the list in the Finder window by the date last modified, ensuring the most recent document you created is at the top of the list.
  • Rename Finder Items: Add Text: Finally, this action takes the client name variable and adds the client name plus a hyphen to the front of a filename.

All in all, this is a pretty simple workflow. I’m sure there are better workflows you can download online somewhere. The exercise of building my own helped introduce me to the power of Automator and ensured the workflow works exactly how I need it.

The Sweet Setup Staff Picks for 2022

We spend an inordinate amount of time sorting through hundreds of apps to find the very best. Our team here at The Sweet Setup put together a short list of our must-have, most-used apps in 2022.

Get the List »

How I Create Placeholder Document Names: Alfred Text Snippets

Though you could use any text snippet app for this portion of the workflow, I’ve opted to use Alfred. A) I’ve already purchased Alfred. B) I think Alfred is perhaps the best app on my Mac.

You could say I’m biased.

But baked nicely inside Alfred are some reasonably powerful text snippet and replacement features. Like TextExpander or Raycast, Alfred can constantly scan your typed text and can replace your text whenever a certain hotkey is triggered.

Given the 3 major document names I have to type 30 times a day, it only makes sense to set each of the document filenames to a text snippet. My hotkeys are set as follows:

  • t18 — triggers the text expansion “T183 – 2021”
  • t1c — triggers the text expansion “T1 Client Copy – 2021”
  • t1e — triggers the text expansion “T1 eFile Confirmation – 2021”

I also have additional hotkeys for less often used — but still quite often used — document filenames like:

  • t1013 — triggers the text expansion “T1013 – 2021”
  • t10e — triggers the text expansion “T1013 eFile Confirmation – 2021”
  • t2c — triggers the text expansion “T2 Client Copy – 2021”

In the case of the “t1e” snippet, I’ve been able to shorten a 42-character filename into a 15-character typing exercise (the text snippet of 4 characters and the presumed SMITH, JOHN client name of 11 characters). And this is on the first time I trigger this workflow. As I mentioned above, the Automator workflow actually copies the client’s name to the clipboard, ensuring my second triggering of the workflow only requires 6 characters of typing.

Not bad.

But how do you trigger these workflows automatically?

Hazel: The Always-Scanning Automator Initiator

Once you allow Hazel access to monitor specific folders in Finder, you can have Hazel perform the heavy legwork on many tedious tasks. Some very smart people with lots of experience have created Hazel workflows for all sorts of uses.

I haven’t yet unlocked Hazel’s power in my professional work. It’s a bummer. And it’s likely an “It’s me, not you” issue. Because many others in my shoes have found a use for Hazel.

It wasn’t until I learned Hazel could trigger a shortcut or an Automator workflow that it all dawned on me. In short order, Hazel went from a “I can’t use that app” to an “I can’t live without that app.”

Once Hazel is given access to a folder and starts to monitor that folder for specific rules, you can have Hazel trigger a pre-created Automator workflow. You can likely see this all coming together, but the workflow looks something like this:

  1. Print a PDF in any of our software and give that PDF a generic name — such as “T1 Client Copy – 2021” — and save it to the Desktop. These generic names are quickly created using Alfred text snippets.
  2. Provide Hazel access to constantly monitor the Desktop.
  3. When a specific rule is met — such as if the name of a PDF is “T1 Client Copy” — triggers the “Rename File” Automator workflow.

  4. Complete the tasks in the workflow and the PDF will be consistently named and in an easily accessible place on the Desktop.

Basically, Hazel is my Automator workflow initiator, constantly scanning my Desktop (among other folders) for specific document names to trigger Automator workflows.

Hazel is surely capable of more than simple Automator workflow triggers. For now, I haven’t expanded my Hazel use beyond this though. I would love for Hazel to be able to search the client name inserted at the front of the PDF filename and automatically move that document to the correct client folder in OneDrive. Maybe there’s a way to do this, but my conclusion has been that I’d need 800+ rules, each created for a specific client name.

That’d be tedious and impossible to maintain.

Estimating Time Saved Renaming Documents

When you get on a roll, you can type out a client’s name and “T1 Client Copy” or “T1 eFile Confirmation” pretty quickly. Early in the day or late in the day, perhaps not. But when in the zone, typing goes a lot faster.

So depending on the time of day, there will be more or less time saved by eliminating the constant typing to rename all these documents. But if I estimate 3,200 documents and 3-5 seconds per document for renaming, I’m going to save anywhere from 160 minutes to 267 minutes renaming documents each tax season. Multiply those hours by a billable hourly rate and the workflow very, very quickly pays for the time it took to build this out.

There are other added benefits to automating file renaming workflows, too. Consistent naming allows for simpler searching. It decreases chances of spelling mistakes. It provides an air of quality when you share that document with a client or a third-party.

I’m disappointed it took me this long to discover Hazel’s tricks. But with the discovery, and combined with Alfred’s simple text snippets, I feel like a wizard pumping out document after document through this heavy tax season.

The Sweet Setup Staff Picks for 2022

We spend an inordinate amount of time sorting through hundreds of apps to find the very best. Our team here at The Sweet Setup put together a short list of our must-have, most-used apps in 2022.

Get the List »