Skip to content

Instantly share code, notes, and snippets.

@dylan-chong
Created November 3, 2017 23:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylan-chong/e7b16a982e604ba62fc52e3ab0f98196 to your computer and use it in GitHub Desktop.
Save dylan-chong/e7b16a982e604ba62fc52e3ab0f98196 to your computer and use it in GitHub Desktop.
Batch rename files
find * | xargs rename -n 's/part-of-filename-to-replace/replacement/' # -n for dry run
@dylan-chong
Copy link
Author

dylan-chong commented Apr 25, 2018

NOTE: This breaks if there are special characters (eg spaces, quotes) in the filenames

@dylan-chong
Copy link
Author

dylan-chong commented Aug 14, 2019

I have found a better way:

Using Vim, look at the instructions for :h rename-files

This is much better because you can confirm the results of the rename manually, and even remove/add files from the list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment