From bca78978097ea60affff1f4d7c79ba03697a3af4 Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Sat, 28 Jun 2014 13:25:29 -0700 Subject: [PATCH] names_to_numbers.rb: add --glob argument. Signed-off-by: Colin McCabe --- names_to_numbers.rb | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/names_to_numbers.rb b/names_to_numbers.rb index c41c316..4538976 100755 --- a/names_to_numbers.rb +++ b/names_to_numbers.rb @@ -48,12 +48,19 @@ class MyOptions "The starting number (defaults to 1)") do |e| opts.starting_number = e.to_i end + myparser.on("--glob GLOB", "-g", + "Specify the glob expression to use. Example: '*/*.mp3'.") do |d| + opts.glob = d + end end parser.parse!(args) raise "invalid num_digits: #{opts.num_digits}" unless opts.num_digits > 0 - raise "must give an extension" unless opts.extension != nil + raise "must specify an extension" unless opts.extension != nil + if (opts.glob == nil) then + opts.glob = "*.#{$opts.extension}" + end return opts end end @@ -65,9 +72,8 @@ def pow(x, y) end return ret end -#.#{$opts.extension}").sort.each do |f| def file_iter - Dir.glob("*.#{$opts.extension}").sort.each do |f| + Dir.glob($opts.glob).sort.each do |f| yield f end end -- 1.6.6.rc1.39.g9a42