I have a bunch of images that were somehow renamed from myimage.jpg
to myimage.jpg_backup
, so the images on my website don't load anymore. How would I recursively find all images ending with _backup
and remove just the _backup
part while preserving the rest of the filename?
I tried something like this:
sudo find . -name "*.jpg_backup" -exec rename -n 's/_backup$//' *.jpg_backup ';'
but it gives me an error:
Can't rename *.jpg_backup *.jpg: No such file or directory
Best Answer
try
rename -v 's/\.jpg_backup$/\.jpg/' *.jpg_backup
the -v gives you detail output. see here How to rename