Bash Rename 360,000 Files Using Find -exec

bashexecfindrename

I've got around 360 000 files like:

./001/1/1.jpg
./001/1/2.jpg
./001/2/1.jpg
./002/1/1.jpg
./003/1/1.jpg
...
pattern: [60 dirs]/[1000 subdirs]/[4-10 files].jpg

I want to rename files using rename for example from *.jpg to *.jpeg. I can't do it with single rename, because I get the error argument list is too long.

Searching for solution, I figured out this, but it renames nothing:

find -maxdepth 2 -mindepth 2 -type d -exec rename -n 's/jpg/jpeg/' {}/* \;

When I check if the {} is expanded replacing rename with echo:

find -maxdepth 2 -mindepth 2 -type d -exec echo "rename -n 's/jpg/jpeg/' {}/*" \;

I get expected result:

rename -n 's/jpg/jpeg/' ./061/61430/*
rename -n 's/jpg/jpeg/' ./061/61431/*
...

If I run any of these rename commands, I rename works. So the should be problem with the {}.

Thank you for help!

Best Answer

find  | prename 's/\.jpg$/.jpeg/'

or if you have oder files in the currunt directory

find 0[0-9][0-9] | prename 's/\.jpg$/.jpeg/'
Related Question