blob: dec3e47f357a7c9b718c19ea4271eb2e9cc512ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#!/usr/bin/env perl
use 5.028;
use strict;
use warnings;
die "you probably wanted to pass '*' as an additional command line argument\n"
if @ARGV == 0;
for (@ARGV) {
my ($name, $ext) =
/\A[0-9]{6}-[0-9]{7} - ([^-]+)- [A-Z].+?\.([^.]+)\z/;
next unless defined $name and defined $ext;
my $target = "$name.$ext";
my $i = 2;
while (-e $target) {
$target = "$name-$i++.$ext";
}
die "would overwrite $target" if -e $target; # check
rename $_, $target;
}
|