[ale] script or app to set all files to lower case (James Taylor)

Chuck Huber chuck at cehuber.org
Tue Aug 28 10:10:32 EDT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> Message: 4 Date: Mon, 27 Aug 2007 22:23:07 -0400 From: "James Taylor" <James.Taylor at eastcobbgroup.com> Subject: Re: [ale] script or app to set all files to lower case To: "Atlanta Linux Enthusiasts" <ale at ale.org> Message-ID: <46D34ECB.9252.0075.0 at eastcobbgroup.com> Content-Type: text/plain; charset=US-ASCII That worked a little better. It renamed all the files and folders at the immediate level, but had problems recursing. The following is an example of the errors generated. mv: cannot move `./SNAPINS/NWCADM32.DLL' to `./snapins/nwcadm32.dll': No such file or directory It looks a little like it's enumerating the file list, and once the directory has been renamed, it can't find it to write the new file name to. -jt James Taylor The East Cobb Group, Inc. 678-697-9420 james.taylor at eastcobbgroup.com http://www.eastcobbgroup.com
>>>> >>> "Michael B. Trausch" <mike at trausch.us> 08/27/07 10:11 PM >>> 
> Michael B. Trausch, on 08/27/2007 10:09 PM said:
>> > James Taylor, on 08/27/2007 10:04 PM said:
>>> >> It's an iSCSI NSS (Novell Storage System) mounted directly on an OES Linux server.
>>> >> Essentially a customized SLES9 server with NSS file system drivers.
>>> >>
>>> >> I forgot to mention that I have a folder depth of at least 20.
>>> >>
>> > 
>> > Oh.
>> > 
>> > Mine is out; you'll need a for loop to run at least that many times.
>> > 
>> > You could do:
>> > 
>> > for i in `seq 1 30`; do
>> > find . | while read OldName; do
>> > NewName=`echo $OldName|tr [A-Z] [a-z]`
>> > mv -v "$OldName" "$NewName"
>> > done
>> > done
>> > 
>> > You might want to get rid of the -v on mv though, or redirect output to
>> > a file.
>> > 
>> > -- Mike
>> > 
> 
> Actually, better solution.  "-depth" makes it reverse order:
> 
> find . -depth | while read OldName; do
> NewName=`echo $OldName|tr [A-Z] [a-z]`
> mv -v "$OldName" "$NewName"
> done
> 
> 


You're on the right track... but you need to add one more option to find...

find . -depth -type f | while read OldName ; do
    NewName=`echo $OldName | tr [A-Z] [a-z]`
    mv -v "$OldName" "$NewName"
done

That will get all the *files* in the tree.  Next, do the same thing with
directories.

find . -depth -type d | while read OldName ; do
    NewName=`echo $OldName | tr [A-Z] [a-z]`
    mv -v "$OldName" "$NewName"
done



Hope this helps.

Enjoy,
    - Chuck
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFG1CzYiR3HaLbYCa4RAniOAJsGCooKF3JFnsHA4yvV8alcT9byHQCgnbrf
MOr6AxgFJ9nyZTVGDpq456M=
=HiNK
-----END PGP SIGNATURE-----



More information about the Ale mailing list