Command-line for Editors, Part 1: Creating a series of alphabetic folders

Nothing strikes more fear and aversion into most normal human computer users than the mere thought of using “The Terminal” for anything. I mean, sure, it’s an admittedly super useful skill to have if you own an IMSAI 8080 microcomputer and an acoustic coupler modem, and need to hack into the Pentagon’s W.O.P.R. mainframe to play a few rounds of Global Thermonuclear War. But why on Earth would anyone else who isn’t fortunate enough to be dating Ally Sheedy ever need to know any of this command-line stuff?

As a post-production video editor, you certainly don’t need to know how to use the command-line. But if you place a high value on your time and sanity, learning basic Terminal functions will open up a whole new world of workflow productivity to your skill set, from automating menial file management tasks, extracting hidden metadata from video clips, or batch processing media files in ways that “off the shelf” tools simply won’t allow you to do.

But if you’re totally new to this, I definitely don’t recommend attempting to learn the command-line by opening up a “Terminal for Dummies” book, and trying to learn everything from the ground up. That may work if you’re a total nerd who is interested in tech for tech’s sake, but if you’re a Muggle who wants immediate gratification, I think the best way to learn and appreciate the power of the command-line is by using it for simple, real-world tasks (and there’s no shame in searching for solutions on StackOverflow and copy/pasting any code examples you may find!)

For the first installment of this “Editor’s guide to the command-line” series, I’ll show you a basic example of the power of the Terminal, by running a simple Bash script that automatically creates a series of empty, alphabetically named folders, saving you the effort of manually creating them in the macOS Finder (or Windows, if you have either Windows Subsystem for Linux or Cygwin installed).

In my specific use case, I had a folder containing thousands of fonts (with each font in its own named subfolder). This folder lives on a NAS share, so it takes several thousand years for the list of fonts to display in the Finder. I wanted to sort all these font folders into subfolders named A through Z, to lighten the load when I open the fonts folder. 

All it takes is running this simple “one-liner” command inside the directory (“directory” is Unix-ese for “folder”) where I want the folders to be located:

for i in {A..Z}; do mkdir "$i"; done

Here’s a video that shows the command in action:

Then, to sort all the font folders into their respective, alphabetized top-level folders, I ran a second command inside of the folder containing the unsorted fonts:

shopt -s nocasematch; for dir in *; do cp -r "$dir" "/Volumes/path/to/alphabetized/folders/${dir:0:1}"; done

Screen recording of the sorting command in action:

For now, you don’t have to worry about what all these commands actually mean. This is just a simple, real-world demonstration of what you can do via the command-line that you can’t do efficiently by clicking around with the mouse in the operating system’s graphical user interface. Hopefully, this will spark some ideas on how learning the command-line can make your life easier as a post-production artist!