PDA

View Full Version : uppers to lowers


jpaulb
07-14-2007, 03:15 PM
I have a folder with file names in upper case which need to be converted to lower case.
I had a script but I think the dog ate it :redface:

Any help out there.

Paul

bluesdog
07-14-2007, 03:54 PM
Something like this?
for myfile in *
do
mv $myfile `echo $myfile | tr 'A-Z' 'a-z'`
done

*Burp!*

jpaulb
07-14-2007, 07:06 PM
I tried the following:

#! /bin/bash
for myfile in *
{
mv $myfile echo $myfile |tr '[A-Z]' '[a-z]'
# rename $myfile echo "$myfile" | tr [A-Z] [a-z]

}
#

mv fails with the waring

mv: target `IMGP0848.JPG' is not a directory


and
rename fails with the warning:
Bareword "IMGP0848" not allowed while "strict subs" in use at (eval 1) line 1.
Bareword "JPG" not allowed while "strict subs" in use at (eval 1) line 1.

Any suggestions??

bluesdog
07-14-2007, 11:07 PM
Your script is missing the grave accent marks: ` (magnified for illustration purposes!)

The line should be exactly as shown below:
mv $myfile `echo $myfile | tr 'A-Z' 'a-z'`You could even just copy and paste the script I posted, give it a name and make it executable....

Sometimes lazy just works :biggrin:

jpaulb
07-19-2007, 02:46 PM
warning
mv: missing file operand

bluesdog
07-19-2007, 11:35 PM
Did you use this file: for myfile in *
do
mv $myfile `echo $myfile | tr 'A-Z' 'a-z'`
doneSorry if previous post was unclear. I didn't mean to use just the single line
The script as posted should work ...

Also, this probably won't work for filenames containing spaces

(There's probably some elegant way to do such a thing, tho... )

jpaulb
07-21-2007, 02:54 PM
Thank you it worked.
After 991 pictures my Pentax istD changed file names from IMGP991.JPG to imgp992.jpg.

Until now have not found a place in the manual discribing how to change the file names.

Paul