1
12 34
I want to see if any element of an array is equal to a file extension
Something like
require 'find'
require 'FileUtils'
src="/folder/on/drive/which/contains/other/folder/and/files"
dest ='another place'
extNot2move = %{jpg,JPG,pdf,PDF,MRW}
Find.find(src) do |fn|
if File.file?(fn)
if extNot2Move.{any of the elements} == File.extname(fn) ## this is
the test I'm interested in
FileUtils.Move(src, dest)
end
end
I think I could do it with a extNot2Move.each with a block following,
but it seems like their should something more concise.
Thanks from a Ruby newbie
Something like
require 'find'
require 'FileUtils'
src="/folder/on/drive/which/contains/other/folder/and/files"
dest ='another place'
extNot2move = %{jpg,JPG,pdf,PDF,MRW}
Find.find(src) do |fn|
if File.file?(fn)
if extNot2Move.{any of the elements} == File.extname(fn) ## this is
the test I'm interested in
FileUtils.Move(src, dest)
end
end
I think I could do it with a extNot2Move.each with a block following,
but it seems like their should something more concise.
Thanks from a Ruby newbie