On Mon, May 12, 2008 at 11:00 AM, Clement Ow
<clement.ow / asia.bnpparibas.com> wrote:
> A snippet of my code are as follows:
>   $selections = ["*","*"]
>   $file_exception = ["RiskViewer*","*.xls"]
>
>   $source = ["C:/Test", "C:/Test"]
>
>   $dest = ["U:/Test","U:/Test"]
>
>
>   sd_a=$source.zip($dest,$selections,$file_exception)
>
>   sd_a.each do |sd|
>   $source, $destination, $selections, $file_exception = sd
>      src = File.join $source, $selections
>      puts src
>      d= $d1
>      dst= File.join $destination, d
>      test = File.join $source, $file_exception

Untested but change this:

>      src1 = Dir.glob(src) - Dir.glob(test)

to:

src1 = $file_exception.inject(Dir.glob(src)) {|result, ex| result -
Dir.glob(ex)}

Also, doing a Dir.glob for each exception can be a lot, why not use
regular expressions
to remove from the result of the first glob? You will have to change
the exceptions
a little bit, but it might be worth it:

["\.txt", "\.sql"].inject(Dir.glob("/home/jesus/*")) {|result, ex|
result.reject{|x| x =~ Regexp.new(ex)}}

This removes from my home folder all files that match ".txt" and ".sql"

Hope this helps,

Jesus.