Skip to content

Instantly share code, notes, and snippets.

@imbdb
Created July 5, 2019 10:37
Show Gist options
  • Save imbdb/d33674b6f41780db7d8c6fb65d1b21b2 to your computer and use it in GitHub Desktop.
Save imbdb/d33674b6f41780db7d8c6fb65d1b21b2 to your computer and use it in GitHub Desktop.
Rename all files to numbers
# Find all files with specified pattern using find and then mv them to new numbered name
# eg. abc.jpeg, sdfs.jpeg,... --> 0001.jpeg,0002.jpeg,...
find -iname '*.jpeg' | # find files
gawk 'BEGIN{ a=1 }{ printf "mv \"%s\" \"%04d.jpeg\"\n", $0, a++ }' | # build mv command ( Change 04d(0000) to your number your files)
bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment