I have a large and messy collection of file--hey who doesn't--some of these are large JPGs (large in this case is an arbitrary number, say 2.5MB) that I want to rename--I want to change the extension from *.jpg
to *.jpeg.
I'd love to do this with a shell script, I'm running BASH 3.2.39(1)
, and I have a feeling this is "simple" task with find
, alas I find find'开发者_运维百科s syntax difficult to remember and the man page impossible to read.
Any and all help with be most appreciated.
Finding and renaming large files could be done like this:
find . -size +2500k -exec rename -s .jpg .jpeg '{}' ';'
What OS are you using? In most repositories there is an app called mmv which is perfect for these kinds of things..
usage:
mmv \*.jpg \#1.jpeg
Install rename (standard tool in your linux installation or with homebrew for mac), then:
rename -s .jpg .jpeg *
or, if you have files in subdirectories too:
rename -s .jpg .jpeg $(find . -name '*.jpg')
for i in *.jpg
do
new_name= $(echo $i|sed 's/.jpg/.jpeg/')
mv $i $new.name
done
精彩评论