Avatar of willsherwood
willsherwood

asked on 

Linux/Unix shell command RENAME

i need to rename all *.JPG to *.jpg  in a particular single directory (no recursion)

how can i accomplish this once i   CD to that directory?

something like   rename *.JPG *.jpg
Linux OS Dev

Avatar of undefined
Last Comment
Tintin
Avatar of farzanj
farzanj
Flag of Canada image

Try this:
for file in $(ls *.JPG)
do
   mv $file ${file%.*}.jpg
done

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of farzanj
farzanj
Flag of Canada image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of willsherwood
willsherwood

ASKER

that was easy!  thanks!
Avatar of Tintin
Tintin

Even easier if you use the 'rename' command.

Unfortunately this comes in two flavours on Linux systems, so you either need to do:

rename .jpg ,JPG *.JPG

Open in new window



or

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

Open in new window

Avatar of Tintin
Tintin

Small typo.

rename .jpg ,JPG *.JPG

Open in new window


should be

rename .jpg .JPG *.JPG

Open in new window

Linux OS Dev
Linux OS Dev

Kernel programming for Linux operating systems can be done with many different languages; C, C++, Python, Perl and Java, which are some of the most common languages used.There are also many different varieties of Linux, such as Ubuntu, Fedora and OpenSUSE.

10K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo