Mass Renaming of Files on OS X or Linux

By | 11/11/2013

If you have a large number of files that you nee to rename, it can be a real pain trying to do it in the GUI or on the CLI. The following script can be used to replace any character or string of characters in the name of every file in a directory.

#!/bin/bash
ls | while read -r FILE
do
mv -v "$FILE" "`echo $FILE | tr 'STRING TO REPLACE' 'STRING TO INSERT' `"
done

Just replace the red sections in the code with your desired strings.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.