Unix command to change all files names in directory to lower case?

Peter Murray pem at po.cwru.edu
Tue Oct 21 18:47:28 EDT 1997


--On Tue, Oct 21, 1997 12:16 PM -0700 "Preston, Linda"
<LPRESTON at ncdc.noaa.gov> wrote: 
> Does anyone know the UNIX command line to change all my file names in my 
> directory on a floppy to lower case.  I have windows 3.1 and can't tell 
> which are upper and lower case.  I thought all of mine would be lower case

> but find that they are not.  Please reply directly to me if possible. 

There isn't a single UNIX command to do it, but if you have Perl, this
should work:

  perl -e 'opendir(DIR,"."); foreach $fn (readdir (DIR)) \
  { rename $fn, lc($fn); }; closedir(DIR)'

Note...this doesn't attempt to resolve duplicates; if you have "FILE" and
"file", "FILE" will overwrite "file" when the rename happens.


Peter
--
Peter Murray, Library Systems Manager                    pem at po.cwru.edu
Digital Media Services                 http://www.cwru.edu/home/pem.html
Case Western Reserve University, Cleveland, Ohio          W:216-368-5888




More information about the Web4lib mailing list