C
Clement Ow
Hi, people I know some of ya might find me familiar but, I really am
still a novice in ruby thus i'll need help once in awhile. I'd
defeinitely appreciate whatever help that is rendered! =)
ok, so back to our topic. I have a code where I would like to traverse
into files and folders and then at the same time pass in exceptions and
then after that select the whole load of files to carry out actions like
copying or deleting. But I'll only need help for the traversing of
folders and the exceptions part. Here's my code:
src1 = []
$source.each do |y|
Find.find(y + "/") do |file|
src1 << file
$file_exception.each do |ex|
src1.delete_if {|x| /#{ex}/ =~ File.basename(file)}
end
end
$source is an array of source paths like ["C:/Del", "C:/My Pictures"]
$file_exception is an array of exceptions like [".txt", ".xls"]
The whole block of code is working fine except that it traverses into
the folders twice, and then parses all the file paths into src1(which is
not what is wanted) Is there any way to improve on my code?
still a novice in ruby thus i'll need help once in awhile. I'd
defeinitely appreciate whatever help that is rendered! =)
ok, so back to our topic. I have a code where I would like to traverse
into files and folders and then at the same time pass in exceptions and
then after that select the whole load of files to carry out actions like
copying or deleting. But I'll only need help for the traversing of
folders and the exceptions part. Here's my code:
src1 = []
$source.each do |y|
Find.find(y + "/") do |file|
src1 << file
$file_exception.each do |ex|
src1.delete_if {|x| /#{ex}/ =~ File.basename(file)}
end
end
$source is an array of source paths like ["C:/Del", "C:/My Pictures"]
$file_exception is an array of exceptions like [".txt", ".xls"]
The whole block of code is working fine except that it traverses into
the folders twice, and then parses all the file paths into src1(which is
not what is wanted) Is there any way to improve on my code?