I wanted to change all of the files extensions in a folder to .jpg using only sed command.
I tried using
sed -i 's/\.*/\.jpg/g' ~/cw/
cw is my folder where i have files like:
cat.jpg
dog.JPG
frog.jpeg
etc.
CodePudding user response:
Using sed
sed -n 's/\(^[^.]*\.\)[jJ][pP]e\?[gG]/mv & \1jpg/p' <(find ~/cw/)
If the dry run indeed changes the files to the expected extension, then you can then execute the command within the sed
command
sed -n 's/\(^[^.]*\.\)[jJ][pP]e\?[gG]/mv & \1jpg/pe' <(find ~/cw/)