owc
April 9, 2008, 10:03am
1
All,
First of all,
Thanks to those who helped out in my previous thread. It was really of
great help. Alright now, another issue i just can figure out, so i
decided to post a new thread
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’ ?
owc
April 9, 2008, 10:32am
2
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
owc
April 10, 2008, 5:25am
3
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!
Thanks and regards,
Clement