C
Clement Ow
Hi, I have a block of code where I would like to traverese into files
using the Find module and search for files and at the same time have
exceptions to the list of files that I want to eventually select. (These
files are in turn used for copying, moving files)
My block of code is as follows:
$file_exception[0] = [".xls", ".txt"]
$file_exception[1] = [".txt"]
$source= ["U:/dest1(1)", "U:/movtest/source", "U:/movtest/new"]
$dest = ["U:/test_1", "C:/MOVTEST/04-08", "C:/DEL/04-08"]
$selections = [*,*,*]
sd_a=$source.zip($dest,$selections)
sd_a.each do |sd|
$source, $destination, $selections = sd
d= $d1
dst= File.join $destination, d
if $file_exception != nil
$source.each do |y|
Find.find(y + "/") do |file|
src1 << file unless $file_exception.each{|x| /#{x}/ =~
File.basename(file)}
end
end
else
src1 = $source
end
i = i + 1
src1.each do |folder|
Find.find(folder + "/") do |file|
:
:
But apparently, the file exception doesnt seem to work.. It doesnt just
exclude the file exceptions that has the file extentions .txt and .xls,
it excludes the whole list of files in the first 2 source paths, and
only executes the files in the 3rd source path. I presume it should be
something really wrong with the:
that I cant quite figure(i tried figuring for days!) Help anyone? =)
using the Find module and search for files and at the same time have
exceptions to the list of files that I want to eventually select. (These
files are in turn used for copying, moving files)
My block of code is as follows:
$file_exception[0] = [".xls", ".txt"]
$file_exception[1] = [".txt"]
$source= ["U:/dest1(1)", "U:/movtest/source", "U:/movtest/new"]
$dest = ["U:/test_1", "C:/MOVTEST/04-08", "C:/DEL/04-08"]
$selections = [*,*,*]
sd_a=$source.zip($dest,$selections)
sd_a.each do |sd|
$source, $destination, $selections = sd
d= $d1
dst= File.join $destination, d
if $file_exception != nil
$source.each do |y|
Find.find(y + "/") do |file|
src1 << file unless $file_exception.each{|x| /#{x}/ =~
File.basename(file)}
end
end
else
src1 = $source
end
i = i + 1
src1.each do |folder|
Find.find(folder + "/") do |file|
:
:
But apparently, the file exception doesnt seem to work.. It doesnt just
exclude the file exceptions that has the file extentions .txt and .xls,
it excludes the whole list of files in the first 2 source paths, and
only executes the files in the 3rd source path. I presume it should be
something really wrong with the:
src1 << file unless $file_exception.each{|x| /#{x}/ =~ File.basename(file)}
that I cant quite figure(i tried figuring for days!) Help anyone? =)