TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [TCLUG:8884] converting uppercase to lowercase



> #!/usr/bin/perl
> foreach $filename(@ARGV) {
>         $newfilename = lc($filename);
>         print "$filename -> $newfilename\n";
>         rename ($filename, $newfilename);
>         }
> 
>         how do I make it recurse the entire tree, tho; and convert the
> filenames?
>         I tried 'find . -depth| mklc ' and 'find . -depth| mklc * ' but it
> gives me a 'broken pipe' error both times. so obviously the output is not
> getting from 'find' to 'mklc'.
>         I don't know perl very well (the script was written with the help of
> ppl on this list); and I forget what the '(@ARGV)' means. I think it's an
> array made from stdin; but don't really have a clue.

ARGV are the arguments on the command line..

you probably want something more along the lines of

#!/usr/bin/perl

@files = <STDIN>;

foreach $filename (@files) {
...

although I can't remember if that is exactly the right syntax for handling
STDIN (do you have to open()/close() it?)

Also, in a pinch, your current program would probably work just by doing

mklc `find . -depth`          # (remember to use backquotes..)

which puts all of the files 'find' returns on the command line and therefore
accessible from @ARGV

-- 
 _  _  _  _ _  ___    _ _  _  ___ _ _  __   "World Domination.  
/ \/ \(_)| ' // ._\  / - \(_)/ ./| ' /(__   Fast" -- Linus Torvalds 
\_||_/|_||_|_\\___/  \_-_/|_|\__\|_|_\ __)                            
[ Mike Hicks | http://umn.edu/~hick0088 | mailto:hick0088@tc.umn.edu ]