Real-World Patterns (No Theory)
This is the practical payoff. In this module, you'll see real-world patterns you can steal and adapt for your own work. Download pipelines, batch file renaming, media processing, file cleanup, and more—taught as templates you can copy, not abstract tutorials. These are the patterns that make Terminal actually useful in daily life.
Rename 100 Files at Once
You have photos named IMG_0001.jpg, IMG_0002.jpg, etc. You want them named vacation-001.jpg, vacation-002.jpg.
In Finder, this takes forever. In Terminal, it's one command.
The Command
Navigate to the folder with your files
Run this:
ls *.jpg | cat -n | while read n f; do mv "$f" "vacation-$(printf %03d $n).jpg"; done
This renames every .jpg file to vacation-001.jpg, vacation-002.jpg, etc.
Breaking Down the Command
That command looks complicated, but it's just small pieces chained together:
ls *.jpg— Lists all files ending in .jpg|— The "pipe" symbol sends output from one command to the nextcat -n— Adds a line number to each filename (1, 2, 3...)while read n f— Loops through each line, storing the number innand filename infdo ... done— The action to repeat for each filemv "$f"— Renames from the original filenameprintf %03d $n— Formats the number with leading zeros (001, 002, 003)
You don't need to memorize this. Save it somewhere and adapt it when you need it. Change "vacation" to whatever prefix you want, and "*.jpg" to match your files.
Key Takeaway
Batch renaming in Terminal can process hundreds of files in seconds. Copy this pattern and adapt it.