How to match filetype with regular expression?
- by Sanarothe
Hi. I'm stuck trying to get a regex to match a filetype in a sorting script.
Dir.foreach(savedirs[0]) do |x|
puts "Matching " + x + " against filetypes."
case x
when x.match(/^.*\.exe$/i) then puts x
when x.match(/\.jpe?g$/) then FileUtils.move(x, sortpath[".exe"], :verbose => true)
when x =~ /\.jpg$/ then FileUtils.move(x, sortpath[".jpg"])
end
end
I can't get any of these to match on in windows. All I need is to confirm that a given filename matches against compatible filetypes.