Skip to content

Instantly share code, notes, and snippets.

@nepsilon
Last active July 7, 2016 06:15
Show Gist options
  • Save nepsilon/1c98c0172310e72814fd to your computer and use it in GitHub Desktop.
Save nepsilon/1c98c0172310e72814fd to your computer and use it in GitHub Desktop.
How to batch rename files with bash? — First published in fullweb.io issue #36

How to batch rename files with bash?

Let’s say we have these files:

ls 
to_be_renamed_1.txt 
to_be_renamed_2.txt 
to_be_renamed_3.txt 

Use the rename command with your substitution pattern:

rename 's/to_be_renamed/got_new_name/' *.txt 

See the new names now:

ls 
got_new_name_1.txt 
got_new_name_2.txt 
got_new_name_3.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment