I have a directory having subdirectories containing images files with a wrong name such like filename.jpg.jpg i want to replace this recursiveley with filename.jpg i have tried:
find ./ -type f -exec sed -i 's/string1/string2/g' {} ;
or
sed -i 's/foo/bar/g' *
but none works
thank you
Advertisement
Answer
find ./ -iname "*.jpg.jpg" -exec rename .jpg.jpg .jpg '{}' ;
If you have a rename
utility which uses perl regular expressions, then use the below command :
find ./ -iname "*.jpg.jpg" -exec rename 's/.jpg.jpg$/.jpg/' '{}' ;