Mixed Case Directory Names

Luke Davis ldavis at shellworld.net
Mon Nov 10 22:27:35 EST 2003

One of the first things the script does, is to place the name of a file in
the "tf" variable.
That file name is "/tmp/renamer.", followed by the current unique process
ID (a number from 1 to five digits).

ls *[A-Z]*

Is a standard ls, with the file spec provided as a (bastardized
(bashtardized?))  regular expression.  That regexp says:

*: zero or more characters of any kind
[: start a character class specification
A-Z: class specification: any characters inclusively between capital A and
     capital Z (that is: the entire capitalized alphabet)
]: Close the class spec
*: any character

So, ls will only list files that have at least one capital letter in their
names.  Otherwise, there would have had to been some error handling which
I did not care to deal with.

Now, we send the output of that ls, via the pipe character (send to
another program) ("|"), into the awk program, which is a text processor.
That program takes each line of input (a single file name--ls outputs
files one per line when sending to programs), and does the following with

1.  Outputs the letters "mv".
2.  Outputs a space.
3.  Outputs the first field of the line (the file name).
4.  Outputs a space.
5A. Runs the "tolower" function, giving it that same first field as the
    string to convert to lower case.
5B. Outputs the result of that function, which is a lower case file name.

It does that for each line, and sends the output to the file named in the
variable "tf" (see the top of the script).
It then sources that same file from $tf.  By sourcing, I mean that it
reads in the contents of that file, and executes them as if they were
originally part of the program.

There is also some business about deleting $tf if it already exists, and
at the end of the program, changing to the initial directory (and
generating an error if that doesn't work), and so on.

If you want to see what the sourced file looks like, remove the last "rm"
statement, then read a file in /tmp, called "renamer.<some numbers>".



On Mon, 10 Nov 2003, Rejean Proulx wrote:

> Thanks, I trust you, but I'm making a copy of this stuff and then I'll run
> it.  Seriously, I wouldn't mind asking you questions about this script.  I
> know that you are storing an ls of the files.  but I'm not quite sure how
> the rest of the thing works.

More information about the Speakup mailing list