Skip to content

Batch Rename

You'll rename a hundred files with one command, after a dry run that shows you what will happen before anything moves.

About

Renaming files by hand is where most people lose an afternoon, whether it's trip photos, printer scans or exports called IMG_4471. One loop fixes all of them in a second. The real skill in this badge is the dry run: you print what would happen, read it, and only then do it for real. The copy you make first is what lets you get the pattern wrong without losing anything.

At a glance

Per requirement
15 XP
Completion bonus
75 XP
Requirements
5
Takes
One evening
Skill level
Beginner (done it a few times)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own

Requirements

  1. 1
    Collect 100 or more badly named files and copy the folder. Phone photos, screenshots and downloads are all fair game. Make a copy and work on the copy, because you'll get the pattern wrong the first time, and everyone does. Take a screenshot of the folder listing. Photo
  2. 2
    Write the rename as a print-only dry run. Write a loop that prints the old name, an arrow and the new name for every file and changes nothing. Then read all 100 lines, looking for the file with a space or a dot in the wrong place. Take a screenshot of the dry run output. Photo
  3. 3
    Run it for real and check that nothing was overwritten. If two files rename to the same name, one of them disappears. Count the files before and after, and the numbers should match. Take a screenshot of both counts. Photo
  4. 4
    Rename a second set using dates pulled from the files themselves. Photos carry a date in their EXIF data, and exiftool reads it. Other files have a modified time you can use instead. Names like 2024-03-14-beach-01.jpg sort themselves, which is the whole point. Take a screenshot of the renamed set sorted by name. Photo
  5. 5
    Undo one rename from a log you kept. Write the old and new names to a text file as the script goes, then reverse one of them from that log. Without that log, a wrong pattern is as bad as deleting the files. Take a screenshot of the log and the restored file. Photo