From 0af243616ea2870796382d778dc1281121714288 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 5 Jul 2020 21:13:12 -0400 Subject: Minor updates from ~/bin --- renumfiles | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'renumfiles') 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; -- cgit v1.2.3