diff options
Diffstat (limited to 'renumfiles')
-rwxr-xr-x | renumfiles | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -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; |