On Mon, Dec 09, 2002 at 10:02:25PM -0600, Shyamal Prasad wrote:
>     "drew" == drew cohan <[EMAIL PROTECTED]> writes:
> 
>     drew> How do I rename all files in a directory matching the
>     drew> pattern *.JPG to *.jpg in a bash shell script?  Thanks to
>     drew> you guys I can check for the existence of jpgs in a
>     drew> directory, but can't seem get 'mv' to rename them for me
>     drew> (always complains that the last argument must be a
>     drew> directory).
> 
> Still another way:
> 
> for i in *.JPG
> do
>   mv $i `basename $i .JPG`.jpg
> done

Simplest alternative without sub-shell nor special command:

for i in *.JPG
do
  mv $i ${i%\.JPG}.jpg
done

It works with any reasonable shell ash/bash/dash/... and uses only mv command. 

Cheers :)
-- 
~\^o^/~~~ ~\^.^/~~~ ~\^*^/~~~ ~\^_^/~~~ ~\^+^/~~~ ~\^:^/~~~ ~\^v^/~~~ +++++
        Osamu Aoki <[EMAIL PROTECTED]>   Cupertino CA USA, GPG-key: A8061F32
 .''`.  Debian Reference: post-installation user's guide for non-developers
 : :' : http://qref.sf.net and http://people.debian.org/~osamu
 `. `'  "Our Priorities are Our Users and Free Software" --- Social Contract


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED] 
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to