Re: "rename" shell command

From: Cordula's Web (cpghost_at_cordula.ws)
Date: 01/26/04

  • Next message: Clint Gilders: "Re: Spam Assassin?"
    To: a.kotsopoulos@tue.nl
    Date: Mon, 26 Jan 2004 15:47:58 +0100 (CET)
    
    

    > I'm looking for the "rename" shell command for the macosx version of
    > bsd. In redhat and possibly other linux distributions the command
    > renames files and supports wildcards and multiple file conversions, as
    > you most likely know. To be more precise here is the man page:

    Here's a script in perl. Use like this:

      ### Append .bak to all *.c files
      $ rename '$_ .= ".bak"' *.c

      ### Remove .bak from all *.c.bak files
      $ rename 's/\.bak$//' *.c.bak

      ### Convert to lowercase, but not for Makefile
      $ rename 'tr/A-Z/a-z/ unless /^Makefile/' *

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

    -- 
    Cordula's Web. http://www.cordula.ws/
    _______________________________________________
    freebsd-questions@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-questions
    To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"
    

  • Next message: Clint Gilders: "Re: Spam Assassin?"