From: Colin Patrick Mccabe Date: Sat, 15 Jun 2013 23:36:02 +0000 (-0700) Subject: names_to_numbers.rb: add --starting-number X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b9f7c888ea28fe5f811083fe0e1f5c665bbc90a7;p=cmccabe-bin names_to_numbers.rb: add --starting-number Signed-off-by: Colin McCabe --- diff --git a/names_to_numbers.rb b/names_to_numbers.rb index 0fac484..c41c316 100755 --- a/names_to_numbers.rb +++ b/names_to_numbers.rb @@ -19,6 +19,7 @@ class MyOptions opts.dry_run = false opts.num_digits = 2 opts.extension = nil + opts.starting_number = 1 $fu_args = { :verbose => true } opts.preserve_names = false @@ -43,6 +44,10 @@ class MyOptions "Preserve the names while changing the numbers.") do |e| opts.preserve_names = true end + myparser.on("--starting-number NUMBER", "-N", + "The starting number (defaults to 1)") do |e| + opts.starting_number = e.to_i + end end parser.parse!(args) @@ -76,7 +81,7 @@ def get_file_name(num) end def rename_files(file) - dst="#{get_file_name(1 + $total_files)}.#{$opts.extension}" + dst="#{get_file_name($opts.starting_number + $total_files)}.#{$opts.extension}" if (file != dst) then FileUtils.mv(file, dst, $fu_args) end