Re: capital ->lower case?
- From: Lew Pitcher <Lew.Pitcher@xxxxxx>
- Date: Tue, 24 Jan 2006 09:03:16 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Birre wrote:
> Lew Pitcher wrote:
>
> roN wrote:
>
>>>> Hi,
>>>>
>>>> I have a dir full of files with capital letter like PICTURE.GIF and I
>>>> need
>>>> all in lower case, is there any function to do this?
>>>> Thank you!
>
>
>
>> Assuming that there are no files with lower-case names that match the
>> upper
>> cased filenames (i.e. no "picture.gif" files already in the
>> directory), and
>> that none of the upper-cased filenames will collide when changed to
>> lower case
>> (i.e. none of "Picture.GIF" vs "PICTURE.GIF"), then this should do the
>> trick:
>>
>> for $FILE in * ;
>> do
>> $file=`echo $file | tr '[A-Z]' '[a-z]'`
>> mv "$FILE" "$file"
>> done
>>
>> There are probably simpler ways to do this, though.
> It should be tr '[:upper:]' '[:lower:]' , since not all users follow
> the rule to limit file names to US ascii.
I'll agree to that one. My solution was "quick and dirty", and I missed
that nuance.
> And it must be echo "$file" ,
Here, I'll disagree with you. The quotes aren't necessary in the echo
statement. Since $file will contain the filename, spaces and all,
echo $file
will output the filename (spaces and all) to stdout.
echo "$file"
would also output the filename (spaces and all) to stdout. There would
be no difference in the output at all
However, quotes would be needed in the
mv "$FILE" "$file"
command, because if either of the variables contained filenames with
spaces, the quotes are needed to bind the components together so that
commandline processing doesn't take them as separate arguments to the mv
command.
> since the rule to never add space in directory and file names"
> is ignored even by developers. (to make windows users feel @ home)
Sorry, but no. Unix filenames have never had the requirement (even
informally) of excluding spaces or other whitespace characters. As far
as the system is concerned, the only characters /not/ allowed in a file
or directory name are the NULL (0x00) character, and the '/' character.
It has been a /convenience/ for shell scripts to avoid filenames with
whitespace, otherwise you have to use quotes. A /convenience/ only, not
a rule.
> /birre Registered Linux User #18410 (http://counter.li.org/)
> SuSE - Because I know nothing :-)
- --
Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
iD8DBQFD1jOjagVFX4UWr64RAvniAJ45+0epvcBoPP6/TogBjP1Bzc3q1gCfQ3m4
cCzXpVpskfj/AXupawUHTcw=
=ZaAC
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: capital ->lower case?
- From: Ralf Fassel
- Re: capital ->lower case?
- References:
- capital ->lower case?
- From: roN
- Re: capital ->lower case?
- From: Lew Pitcher
- Re: capital ->lower case?
- From: Birre
- capital ->lower case?
- Prev by Date: Re: After installation no Internet
- Next by Date: Re: After installation no Internet
- Previous by thread: Re: capital ->lower case?
- Next by thread: Re: capital ->lower case?
- Index(es):
Relevant Pages
|