Created
March 12, 2020 23:29
-
-
Save cirrusUK/f04c7ed4721089b916c3431a5d0879e1 to your computer and use it in GitHub Desktop.
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 | |
# rename.pl -- rename files by finding a fixed pattern and replace it by other | |
# Carlos Duarte, 031105 | |
# a clone of the rename(1) utility present in most linux distributions | |
use strict; | |
if (@ARGV < 3) { | |
print "usage: $0 srcpat dstpat files...\n"; | |
exit 1; | |
} | |
my $srcpat = shift; | |
my $dstpat = shift; | |
for (@ARGV) { | |
my $old = $_; | |
s/\Q$srcpat\E/$dstpat/; | |
my $new = $_; | |
$old eq $new and next; | |
print "$old -> $new\n"; | |
rename $old, $new; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment