Batch rename files and folders

Batch rename files and folders

IDEs and editors usually offer nice refactoring functionalities but renaming files and folders in batch still feels like a hard task. 

Here is a bash command to find each occurrence of 'foo' and replace it with 'bar', for all files and folders contained in the given path.


# Find foo and replace with bar in current path
$ find . -depth -name '*foo*' -execdir bash -c 'mv -i "$1" "${1//foo/bar}"' bash {} \;

Should you need something more sophisticated, you may give the Renamer node module a try.