0
我被困在試圖獲得正則表達式來匹配排序腳本中的文件類型。如何使用正則表達式匹配filetype?
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
我不能得到任何這些匹配在Windows中。我需要的是確認給定的文件名與兼容的文件類型匹配。
你而尋找的文件擴展名不是文件類型。 – Gumbo 2010-04-10 08:12:08