Skip to content

Instantly share code, notes, and snippets.

@terrycojones
Created September 15, 2016 16:09
Show Gist options
  • Save terrycojones/aac73224f6df7a600314cf7a31f8691b to your computer and use it in GitHub Desktop.
Save terrycojones/aac73224f6df7a600314cf7a31f8691b to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
# Usage: rename perlexpr [files]
($op = shift) || die "Usage: rename perlexpr [filenames]\n";
if (!@ARGV) {
@ARGV = <STDIN>;
chop(@ARGV);
}
for (@ARGV) {
$was = $_;
eval $op;
die $@ if $@;
rename($was,$_) unless $was eq $_;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment