Files & Folders

Undo an accidental batch rename

Renaming does not touch file contents, so nothing is corrupted — the names are the loss. Names can often be reconstructed from embedded metadata (EXIF, ID3, document properties) or from the script's own logic.

Stop doing this first

The safe order of operations

  1. 1

    Stop writing to the folder and take a copy of it.

  2. 2

    Recover the exact command from shell history — a reversible rename can often be inverted.

  3. 3

    Rebuild names from embedded metadata where the file type carries it.

  4. 4

    Use content hashes to match the renamed files against any backup, cloud copy or old listing.

Commands that do the work

Find the original command

history | grep -i -E 'rename|mv |for f in'

Rebuild photo names from EXIF

exiftool '-FileName<CreateDate' -d '%Y-%m-%d_%H%M%S%%-c.%%e' .

Match against a backup by content

find . -type f -exec md5sum {} + | sort > current.md5

Realistic odds

Likely recoverable when metadata exists; otherwise partial.

Your case will differ in the details. Load this scenario into the recovery form and add what you already tried — you'll get a plan for your exact situation.

Get my recovery plan

Related guides