Skip to content

Instantly share code, notes, and snippets.

@chrismacdermaid
Forked from trammell/rename
Created September 8, 2017 15:47
Show Gist options
  • Select an option

  • Save chrismacdermaid/493c539e53d72c825e797b67c7e5e14d to your computer and use it in GitHub Desktop.

Select an option

Save chrismacdermaid/493c539e53d72c825e797b67c7e5e14d to your computer and use it in GitHub Desktop.

Revisions

  1. @trammell trammell revised this gist Jul 18, 2011. 1 changed file with 2 additions and 5 deletions.
    7 changes: 2 additions & 5 deletions rename
    Original file line number Diff line number Diff line change
    @@ -8,12 +8,9 @@ if (!@ARGV) {
    chomp(@ARGV);
    }


    foreach $_ (@ARGV) {
    for (@ARGV) {
    $old_name = $_;
    eval $regexp;
    die $@ if $@;
    rename($old_name, $_) unless $old_name eq $_;
    }

    exit(0);
    }
  2. @trammell trammell created this gist Jul 18, 2011.
    19 changes: 19 additions & 0 deletions rename
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    #!/usr/bin/perl
    # Usage: rename perlexpr [files]

    ($regexp = shift @ARGV) || die "Usage: rename perlexpr [filenames]\n";

    if (!@ARGV) {
    @ARGV = <STDIN>;
    chomp(@ARGV);
    }


    foreach $_ (@ARGV) {
    $old_name = $_;
    eval $regexp;
    die $@ if $@;
    rename($old_name, $_) unless $old_name eq $_;
    }

    exit(0);