Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find and rename files

Status
Not open for further replies.

diwin

Technical User
Nov 29, 2002
218
CA
I need to find and rename all .JPG files to .jpg in a folder with subfolders. How would I go about this?

Daniel Dillon
O o . (<--- brain shrinking at rate shown.)
 
get rename.

Code:
find -name "*.JPG" -exec rename 's/.JPG/.jpg/' {} +

rename takes regular expressions. I guess more recent versions than mine already contain an -R(ecursive) switch, so you can omit the find.

maybe it is then:
Code:
 rename -R 's/.JPG/.jpg/' "*.JPG"
but you have to have a look at the manual. My version belongs to perl v5.10.0

don't visit my homepage:
 
Hi

stefanwagner said:
My version belongs to perl v5.10.0
Depends on distribution. [tt]rename[/tt] with that syntax I usually met on Debian and its descendants. On other distributions a different [tt]rename[/tt] is used, part of util-linux or util-linux-ng package.
Code:
find -name "*.JPG" -exec rename '.JPG' '.jpg' {} +

Feherke.
 
That's something I didn't know - never knew there was a rename in Linux. I've always used mv. Must have crept in some time after SRV3.
 
Simply

Code:
rename 's/.JPG/.jpg/' *.JPG

works from the target folder in Ubuntu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top