T
Trick Nick
Im writing this program that is suppose to rename files using regular
expressions. I am suppose to pass 3 line arguments: the directory in
which to rename files, a regular expression that matches files to be
renamed, and a new extension to add to the end of files. It should run
as follows:
/fixname dir 'pattern' .ext
Im really really confused on reg. expressions and file directories so if
someone can point me in the right direction or help me get started this
would be greatly appreciated. I understand that ARGV is an array or
arguments passed into the program so it should be something like
currentDirectory = Dir.new("#{ARGV[0]}) and then I should prolly do
somethign along the lines as DirectoryEntries =
currentDirectory.sort_entries
if DirectoryEntries.include?('pattern or ARGV[1]') == true
then DirectoryEntries.sub("pattern", "#{ARGV[3]")
else
puts directoryEntries
I dunno someone with a bit more knowledge can you please help me with
syntax, or logical errors in my assumptions I would really appreciate it
THANKS.
expressions. I am suppose to pass 3 line arguments: the directory in
which to rename files, a regular expression that matches files to be
renamed, and a new extension to add to the end of files. It should run
as follows:
/fixname dir 'pattern' .ext
Im really really confused on reg. expressions and file directories so if
someone can point me in the right direction or help me get started this
would be greatly appreciated. I understand that ARGV is an array or
arguments passed into the program so it should be something like
currentDirectory = Dir.new("#{ARGV[0]}) and then I should prolly do
somethign along the lines as DirectoryEntries =
currentDirectory.sort_entries
if DirectoryEntries.include?('pattern or ARGV[1]') == true
then DirectoryEntries.sub("pattern", "#{ARGV[3]")
else
puts directoryEntries
I dunno someone with a bit more knowledge can you please help me with
syntax, or logical errors in my assumptions I would really appreciate it
THANKS.