Six Colors
Six Colors

by Jason Snell & Dan Moren

This Week's Sponsor

Clay - A beautiful relationship manager for macOS and iOS, built automatically from email, Contacts, calendar, iMessage, LinkedIn, and more. Try it free for 60 days.

By Jason Snell

Automate This: Audio archiving via Shortcuts

This one not-so-simple shortcut removed 62 percent of the data from this folder!

Earlier this week Dan wrote about building an automation to archive a bunch of podcast projects. I’ve been using a shell script written by a friend to do something similar, but Dan inspired me to up my automation game and build a Shortcuts-based podcast-archiving tool of my own.

Dan’s shortcut, while great, has a big limitation: it uses Zip archives, and compressing audio files—especially the huge uncompressed audio files used in podcast editing—is not its strength. The files take a long time to compress, and they don’t compress the files as much as lossless audio formats like FLAC and Apple Lossless do.

I built a new Shortcut that accepts folders as input (via the Quick Actions option in the Finder) and then walks through each folder one by one, looking for lossless audio files—WAVs and AIFFs—and encoding them in the lossless FLAC format.

I had assumed that Apple would provide a way for Shortcuts to encode media into Apple Lossless format, but it doesn’t. The Encode Media action can encode audio, but only to M4A or AIF formats1. Instead, I retreated to the command-line, since Apple provides a utility called afconvert that will let you convert audio files between an enormous number of formats, including not just Apple Lossless but the even more widely supported (and slightly more efficient) FLAC.

The trickiest parts of the entire shortcut involve properly composing the Run Shell Script command that will kick off the file conversion. To do so, I have to use the file’s File Path attribute twice—once as the source file, and a modified version (using the Replace Text action) as the destination location. I chose to rewrite file.wav as file-wav.flac so that I could return the file to its original format with a corresponding decompression shortcut.

building

Almost nothing else in my podcast project files actually needs to be compressed—it’s mostly tiny text files and compressed audio files (like MP3s and M4As) that can’t really be compressed any smaller. The only outlier is the Logic Pro project package itself, because that can be pretty large—so my shortcut looks for any Logic projects and zips them up.

The final step is just to provide a way to tell that a folder has been compressed: I append a parenthetical “(compressed)” to the end of the folder’s name and give it a colored label in the Finder.

The results are pretty impressive. My 5.85 GB project was reduced to 2.2 GB in about a minute, compared to about five minutes to make a 3.2 GB Zip archive.

As I mentioned above, I also wrote a corresponding shortcut that looks for any of my FLAC files, as well as the zipped-up Logic file, and undoes the compression. The resulting Logic projects open normally, and find all their accompanying audio files, making this a successful experiment—and freeing up a lot of space on my home server.

You can download the Compression and Decompression shortcuts if you like. Thanks for the inspiration, Dan!


  1. This action really needs an update! 

If you appreciate articles like this one, support us by becoming a Six Colors subscriber. Subscribers get access to an exclusive podcast, members-only stories, and a special community.


Search Six Colors