Threads for melonism

  1. 2

    I’ve dropped Larry's filename fixer into ~/bin for as long as I can remember. It’s from the Perl Cookbook and that Larry.

    #!/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 $_;

    It lets you apply perlre to file renaming operations:

    $ rename 's/foo-(\d+)/$1-bar/' *.baz

    More examples and notes here.

    Unfortunately my ~/bin also contains cvs-wtf-arg:

    cvs up 2>/dev/null | grep "^\?"

    because I work on one project that still uses CVS. If you know why I need this then I apologise.