Click to See Complete Forum and Search --> : Rename Script


Vectorman
03-09-2005, 10:47 PM
Here's my problem...

I have several directories of Pictures where the extenstion is .JPG (capital letters) I need a quick way to look for the captial letters and change it to lowercase letters.

Any ideas.

Joel

flukshun
03-09-2005, 11:53 PM
find something something

haha, sorry im at work and i thought i'd actually remember the syntax if i started typing.

thaddaeus
03-10-2005, 12:09 AM
a script that checks each char in the filename, if char == A then a to new char else char to new char, somthing along those linse useing a loop of somesort for each filename, or if theres a tolowercase call that would work, just do tolowercase *.jpg and that would defanantly do it, i know it can be done (toLowerCase) in php, java, but those are the only two languages i know.

davisfactor
03-10-2005, 03:07 PM
Here's how to change the entire filename to lowercase:


$ for i in *; do mv $i `echo $i | tr A-Z a-z`; done


And here's another one in my examples file:


Another renaming script. To rename test.jpg.JPG.jpg to test.jpg
for i in `ls *.jpg.JPG.jpg`; do c=`echo $i | cut -d . -f 1`; mv $i $c.jpg; done


The last one assumes that there are no periods in the filename aside from the one before the extension.

I'm sure you can figure the rest out :)

psych-major
03-10-2005, 07:50 PM
Wow, something that's actually easier in M$!

In DOS it would be:
ren *.JPG *.jpg

Weird...

bwkaz
03-10-2005, 08:14 PM
But DOS itself is case-insensitive (and case-destroying -- it converts everything to uppercase, although DOS shells in recent Windows versions don't do this anymore), so you wouldn't have any reason to do this in DOS. :p

davisfactor
03-11-2005, 01:46 PM
Now let's take your DOS statement and tell it to NOT rename a file if the first character is a T.

:D