开发者

finding and renaming large *.jpg to *.jpeg

开发者 https://www.devze.com 2023-03-02 01:34 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消