-
-
Save chrismacdermaid/493c539e53d72c825e797b67c7e5e14d to your computer and use it in GitHub Desktop.
Perl rename script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/perl | |
| # Usage: rename perlexpr [files] | |
| ($regexp = shift @ARGV) || die "Usage: rename perlexpr [filenames]\n"; | |
| if (!@ARGV) { | |
| @ARGV = <STDIN>; | |
| chomp(@ARGV); | |
| } | |
| for (@ARGV) { | |
| $old_name = $_; | |
| eval $regexp; | |
| die $@ if $@; | |
| rename($old_name, $_) unless $old_name eq $_; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment