Changing upper-case filenames to lower-case

Randal Schwartz merlyn at iwarp.intel.com
Wed Nov 22 11:14:00 AEST 1989


In article <3116 at jarthur.Claremont.EDU>, kfink at jarthur (Kevin Fink) writes:
| Is there an easy way to change all the upper-case characters in a filename
| (or set of filenames) to lower-case?
| 
| Whenever I transfer files from my PC to the mainframe the filenames get
| changed to all caps. This is really annoying.

Deja vu.  Didn't we just answer this one?

The solution in Perl:

perl -e 'for$f(<*>){($_=$f)=~y/A-Z/a-z/;rename($f,$_)unless$f eq$_;}'

The solution in sh, tr, echo:

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

There.  Isn't this in the FAQ list?

Just another Perl hacker,
-- 
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel's iWarp project, Hillsboro, Oregon, USA, Sol III  |
| merlyn at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn	         |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/



More information about the Comp.unix.questions mailing list