22/11/2015

How to bulk rename file extension in Linux or Mac

By snorlaxprime

There are times where you want to rename file extension or file ending in bulk, e.g.: from

Something_ONE.jpg to Something.jpg

Someotherfile_ONE.jpg to Someotherfile.jpg

the following command can be used, but before test it with the following

ls *_ONE.jpg

for file in *_ONE.jpg
do
 ls "$file" 
done

If the above command return the right files then you can rename the files using:

for file in *_ONE.jpg
do
 mv "$file" "${file%_ONE.jpg}.jpg"
done