Tuesday, February 08, 2011

Find and Rename files in Linux

I had to rename many files (in particular their extensions) which were spread throughout many folders.

I already knew find and rename utilities but I had never used them together...

here's the command line to rename all files in all the folders of the current directory with extension .first to .second

find . -name "*.first" -exec rename -v 's/\.first$/\.second/' {} +

hope this helps :)