Posted on Leave a comment

How to bulk rename file extension in Linux or Mac

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

Leave a Reply

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