From: Trick Nick Date: 2008-10-03T14:53:16+09:00 Subject: Reg. Expressions with file directories 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[i].include?('pattern or ARGV[1]') == true then DirectoryEntries.sub("pattern", "#{ARGV[3]") else puts directoryEntries[i] 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. -- Posted via http://www.ruby-forum.com/.