How can I rename images/ files recursively? For example:
folder
- subfolder1
- a-copy.jpg
- subfolder2
- b-copy.jpg
- subfolder3
- c-copy.jpg
I would like to get:
folder
- subfolder1
- a-thumb.jpg
- subfolder2
- b-thumb.jpg
- subfolder3
- c-thumb.jpg
I tried:
for i in $(find . -iname '*.jpg') ; do rename 's/-copy/-thumb/' *.jpg; done
Doesn't work off course! Any idea?
With
rename
, check with-n
for a dry-run first like so:... and if satisfied with the naming output, remove
-n
and run it again to do the actual renaming.or in a loop, first, check with
echo
included as follows (run from within the parent directory containing thefolder
directory or alternatively provide/full/path/to/folder/*/*.jpg
below):... and if satisfied with the naming output, remove
echo
and run it again as follows:... to do the actual renaming.
To include other file extensions (Case Sensitive), add them in a brace expansion like
folder/*/*.{jpg,JPG,png,PNG}
etc.