some fixups to snarf_mail scripts
[cmccabe-bin] / names_to_numbers.rb
index 9439fd1..c41c316 100755 (executable)
@@ -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,8 +81,10 @@ def get_file_name(num)
 end
 
 def rename_files(file)
-  FileUtils.mv(file, "#{get_file_name(1 + $total_files)}.#{$opts.extension}",
-               $fu_args)
+  dst="#{get_file_name($opts.starting_number + $total_files)}.#{$opts.extension}"
+  if (file != dst) then
+    FileUtils.mv(file, dst, $fu_args)
+  end
   $total_files = $total_files + 1
 end