aboutsummaryrefslogtreecommitdiff
path: root/renumfiles
diff options
context:
space:
mode:
Diffstat (limited to 'renumfiles')
-rwxr-xr-xrenumfiles16
1 files changed, 13 insertions, 3 deletions
diff --git a/renumfiles b/renumfiles
index 28ff2b9..1f57776 100755
--- a/renumfiles
+++ b/renumfiles
@@ -16,11 +16,21 @@ if($ARGV[0] =~ /^\d+$/) {
}
$pattern = $ARGV[0] || usage;
-$pattern =~ s/\%d/%02d/;
+usage if -f $pattern;
+
+shift;
+if(@ARGV >= 1000) {
+ $places = 4;
+} elsif (@ARGV >= 100) {
+ $places = 3;
+} else {
+ $places = 2;
+}
+
+$pattern =~ s/\%d/%0${places}d/;
if($pattern !~ /\%\d+d/) {
- $pattern = "${pattern}_\%02d.jpg";
+ $pattern = "${pattern}_\%0${places}d.jpg";
}
-shift;
@files = @ARGV;
usage unless @files;