[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [OT] Changing the case of filenames



On Friday, Apr 29th 2005 at 09:39 -0400, quoth David Niemi:

=>I am running a fortran program which requires all input file names to be
=>uppercase.  As things were originally done in Windo$e all the filenames
=>are mixed case (with numbers).
=>
=>Searching around I came across the "tr" command, but my difficulty comes
=>in trying to use this from the command line (or even in a bash script).
=>
=>    mv * | tr [a-z] [A-Z]

I am amused by your first attempt. :-) 

=>
=>Does not work as mv requires a directory for the objective with multiple
=>files.  All of the scripts that I have seen are mainly for changing the
=>case of text in a text file so wouldn't work for me.
=>
=>So, how would I do this?
=>
=>TIA Dave
=>

>From the camel book:

722 > cat `which rename`
#!/usr/bin/perl
$op = shift;
for (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}
723 >

rename 'tr/A-Z/a-z/' *

I like this one because you can use it with full perl regex capabilities.

e.g.,

rename 's/\.JPG$/.jpg/' *.JPG

etc...

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]