[ale] rename large number of files

Fletch fletch at phydeaux.org
Tue Apr 29 14:22:32 EDT 2003


>>>>> "mkii" == mkii  <White> writes:

    mkii> I have a large number (50-60) of text files that are named
    mkii> without a .txt on the end most are named in this type
    mkii> fashion 222.333-444

    mkii> I am a newbie to Linux and was trying to use "mv" to delete
    mkii> the "." and "-" in the name and add a .txt on the end.

rename 'y/.-//d;$_.=".txt";' ???.???-???

#!/usr/bin/perl -w
# rename - Larry's filename fixer
$op = shift or die "Usage: rename expr [files]\n";
chomp(@ARGV = <STDIN>) unless @ARGV;
for (@ARGV) {
    $was = $_;
    eval $op;
    die $@ if $@;
    rename($was,$_) unless $was eq $_;
}


-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
770 294-0820 (m)      |  scary questions." -- Jules                =(___)=
                      |                                               U
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list