Making the most of Shortcuts automations in macOS Tahoe: Podcasting file management

The automation features added in macOS Tahoe are remarkably useful.

Over the past several months, I’ve been on a bit of a quest to refine and enhance the essential automations on my Mac. While I’ve relied on a hodgepodge of tools over the years, the primary impetus for this bout of self-improvement was the introduction of automations for Shortcuts in macOS Tahoe—a long-awaited feature that has been around for many years on iOS and whose lack I’ve repeatedly decried during that time.

Many of the tools I previously used were totally fine—good, even—but I am a big believer in using first-party options where possible, both to figure out the extent of their capabilities, as well as to reduce dependence on other tools that might not offer full cross-platform support or might use non-sanctioned methods that could go away. It’s hard enough to get most people to start trying automations, without having to refer them to third-party apps.

One place that I’ve relied on automation over the past several years is in managing my podcasts. Jason and I have, of course, collaborated on a podcast notes workflow, but most of my needs are more mundane. To wit, recording podcasts requires managing a lot of files, and dealing with all of that manually was something I didn’t really want to have to spend time thinking about.

My previous solution relied on Hazel, an excellent Mac automation tool that can watch folders and carry out actions based on what happens in them. Apple itself has long offered a similar capability called Folder Actions, though it’s somewhat hidden these days and requires using AppleScript to at least bridge over to Shortcuts, something that I didn’t want to have to deal with.

So I set out trying to get two of my major podcast file management workflows into automations.

Recording!

The first task is dealing with the files that I record. I’ve long had a Podcast Sorter shortcut that helps put files into sub-folders, based on the show I’m recording. Initially, this was a shortcut that was triggered by Hazel; later on I adjusted it to be fired off by Audio Hijack’s built-in automation features. The annoyance there was that I maintain different Audio Hijack sessions for each show I regularly record, and that meant having each of them set up to trigger those shortcuts. But Shorcuts’s automation feature allowed me to centralize this functionality. Especially once Apple added the much-needed ignore subfolders criteria.

My Podcast Sorting shortcut makes sure files end up in sensible, organized folders.

The shortcut itself is largely the same as the earlier version I linked above, with a few minor refinements from over the years.1 I did run into one thing that I thought was going to be a challenge, but ended up being fine, if surprising: because this automation watches for changes in the In Progress folder where Audio Hijack keeps the files it’s actively recorded, the shortcut is actually triggered right when the recording files first appear. Thus, those files are instantly moved to the correct sub-folder…while the recording is still happening. To my 1980s/90s-trained brain, I thought for sure this would cause some huge corruption errors with the recordings, but apparently modern file systems can handle it without, if you will, missing a beat. Wild, but true. I’ve been using this for weeks now with nary a problem.

Archival quality

The second podcast file management task I had automated was archiving old recordings to my Network Attached Storage. This was previously another Hazel workflow that would watch my local folder of podcast recordings, take any episode folder that was more than two weeks old, compress it into an archive, and move it to the corresponding folder on my NAS.

I figured replacing that with a Shortcuts automation would be relatively simple and it was…with some caveats. First off, instead of using the Hazel technique of watching the folder, I just have this automation run every day at 3am. That’s plenty efficient for me; there’s no need it needs to be alerted as soon as a folder is two weeks old—and in fact, the old Hazel routine timing meant it often started doing the archiving right as I was recording the current episode of the same show. Schedules!

While the shortcut itself is fairly straightforward, the challenges came—surprisingly enough—in terms of dealing with the file system.

My podcast file organization, which the shortcut needs to traverse, is structured like so:

Podcasts/
├── In Progress
├── Show Folder/
│ ├── Show Name - Date/
│ │ ├── Recording File
│ │ ├── Recording File
│ │ └── ...
│ ├── Show Name - Date/
│ │ ├── Recording File
│ │ ├── Recording File
│ │ └── ...
│ ├── show asset file
│ └── ...
├── Show Folder/
│ ├── Show Name - Date/
│ │ ├── Recording File
│ │ ├── Recording File
│ │ └── ...
│ ├── Show Name - Date
│ ├── show asset file
│ └── ...
├── ...
├── Miscellaneous/
│ ├── Recording - Date/
│ │ ├── Recording File
│ │ ├── Recording File
│ │ └── ...
│ ├── Recording - Date
│ └── ...
├── asset file
└── asset file

First, there is—amazingly to me—no way to identify a given file as a folder. Let’s say you’re using Shortcuts to iterate through the contents of a folder and you just want to identify each sub-folder. The very powerful Filter Files action lets you add a bunch of criteria, pulling out files with a certain extension, path, date, name, etc. In the olden days, you probably could have filtered by kind2, but “kind” is not a criteria in Shortcuts’s Filter Files action, only file extension. And folders apparently neither have an extension nor are regarded as having no extension.3 Which I believe is a bug, but doesn’t really help me.

While there are some quirks to getting Shortcuts to do what you want, this podcast file archiving workflow has been pretty reliable.

In the end, the most reliable method I found of isolating folders was to Filter Files where file size is less than 1KB. It is, of course, not impossible that I would have another file that small there, but it is enough of an edge case that I’m not worried about it.4

My next challenge came from a similar source. Once I identify all the Show Folders, I need to identify the archivable episode folders. Again, I filtered by the 1KB rule to just pull out folders, as well as by the date modified to find the old episodes, buuuuut I ran into another issue. Some of my folders contain Logic or Garage Band projects as show assets (either as templates or for other utility reasons). And guess what? Those are technically packages, which are basically folders…which make them files that are less than 1KB. So I had to specifically filter out files where the file extension was logicx or band. Once again, a problem that could be solved if I was able to just filter out specifically folders.

Now that I’ve identified the files that need to be archived, let’s get to it. First step, compress the folder into an archive. Easy enough, as Shortcuts offers the Make Archive action, but that feature has a quirk. When it creates an archive, it exists…in the ether. Well, not strictly true, but it’s not the same behavior as if you select files or folders in the Finder and choose Compress: there the archive just pops into being, right next to the file you’ve compressed. In Shortcuts, that archive doesn’t stick around unless you subsequently use the Save File action to put it somewhere. Otherwise, it happily makes the archive, and then just tosses it in the dumpster.5

Second point, I had to be sure to give the archive an explicit name. When you compress files in the finder, the archive is by default the same name as the item being compressed, just with a ZIP at the end. Not so when you do it in Shortcuts. (I found this out/remembered the hard way, after I started seeing files on my NAS show up with long and random alphanumeric strings.)

The last challenge was to ensure that the archives were moved to the correct corresponding sub-folder on my NAS. In Hazel, I’d accomplished this via a feature that copies the directory structure and by having my NAS’s archive folder essentially mirror the hierarchy of my Podcasts folder. Shortcuts doesn’t really have a corresponding capability, so I had to come up with my own solution. So, I got the name of the parent directory for the folder being archived (which is the name of the show) and then used the Save File feature’s subpath parameter to specify the folder structure within the Podcasts folder on my NAS.

I appreciate that sending notifications lets me check the next day that the task happened.

The original is then deleted from my local machine6, and a notification sent that says the folder has been archived.

To my delight, this has all generally worked pretty well. Most of the technical issues were limitations with what Shortcuts lets you do, but the automation itself has been solid once those bugs were worked out. While it took way too long for macOS to get Shortcuts automation as a feature, the actual results have been great and, as per my above goals, allowed me to rely more on first party tools for most if not all of the automation workflows I’ve relied on.

I’ve also continued to use automation to push forward another repetitive task: keeping track of my finances. But that’s another post altogether, so stay tuned.

For a while there was a bug where Shortcuts would fail to move files to the appropriate folders, for reasons I couldn’t divine, so I temporarily replaced it with copying those files, meaning I had to go and manually clean out the originals. A pain. Fortunately, this seems to have been resolved. ↩

Pull up the old Find dialog in Finder and you can easily use the criteria dropdown there to find by Kind and then select Folder. ↩

Weirdly, you can set Filter Files to show files where “File Extension is not anything” which doesn’t seem to give me any results, even in a folder with items that have no visible extension in the Finder or Terminal. Either that is broken or it’s a completely useless feature. ↩

I could have also moved non-folders out of that folder, I expose, but I (perhaps selfishly) wanted to adapt the shortcut to me rather than having to adapt my behavior just to satisfy a shortcut’s bizarre limitations. ↩

In the time-honored tradition of a computer doing exactly what you tell it to, no more and no less. ↩

I ran a test version for several weeks that instead moved the original files to an Archive folder in my Podcasts directory, just to be sure everything was working as intended. I also explicitly ignored that folder at the beginning of my workflow, just to avoid any weird circular behavior. ↩