Exceptions in file copying

All,
First of all,
Thanks to those who helped out in my previous thread. It was really of
great help. :slight_smile: Alright now, another issue i just can figure out, so i
decided to post a new thread :wink:

source=%w[C:/movtest/testing
C:/movtest/testing/new
U:/movtest/source
U:/movtest/new
U:/movtest/new1]

dest=%w[U:/test_1/ U:/dest1/ U:/dest2/ U:/dest3/ U:/dest4/]

selections=[“2008*”, “2008*”, “2008*”, “asd*”, “asd*”]

here i combine those 3 arrays into 1 multi-dim array

sd_a=source.zip(dest,selections)
#puts sd_a

sd_a.each do |sd|
source, destination, selections = sd
src = File.join source,selections
puts “Source: #{src}”
puts “Dest: #{destination}”

FileUtils.cp_r Dir.glob(src), destination

puts “File Copy Test:Success”
end

I have a folder in C:\movtest\testing\ and i want to leave the last day
of the mth untouched(which means i dont wanna copy them over to the dest
path.) For example, I wanna copy any file or folder starting with 2008
but I want to keep 20080331 which is the last day of the previous mth
untouched. Is there any way i can put an exception to the command,
‘FileUtils.cp_r Dir.glob(src), destination’ ?

From: Clement Ow [mailto:[email protected]]

I have a folder in C:\movtest\testing\ and i want to leave

the last day

of the mth untouched(which means i dont wanna copy them over

to the dest

path.) For example, I wanna copy any file or folder starting with 2008

but I want to keep 20080331 which is the last day of the previous mth

untouched. Is there any way i can put an exception to the command,

‘FileUtils.cp_r Dir.glob(src), destination’ ?

Dir.glob returns an array

irb(main):012:0> Dir.glob(“2008*”)
=> [“20080331”, “2008abc”, “2008def”, “2008ghi”]

and you can (easily) subtract arrays by the “-” operator

irb(main):014:0> [1,2,3] - [3]
=> [1, 2]

so you can do something like

irb(main):015:0> Dir.glob(“2008*”) - [“20080331”]
=> [“2008abc”, “2008def”, “2008ghi”]

kind regards -botp

Dir.glob returns an array

irb(main):012:0> Dir.glob(“2008*”)
=> [“20080331”, “2008abc”, “2008def”, “2008ghi”]

and you can (easily) subtract arrays by the “-” operator

irb(main):014:0> [1,2,3] - [3]
=> [1, 2]

so you can do something like

irb(main):015:0> Dir.glob(“2008*”) - [“20080331”]
=> [“2008abc”, “2008def”, “2008ghi”]

Exactly what i wanted! :slight_smile:
Thanks and regards,
Clement

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs