From: Clement Ow Date: 2008-04-09T11:03:26+09:00 Subject: Re: Do arrays use up alot of memory space? Thanks Botp and Philip for the help! ;) anyway, ans philip, the network i'm running is quite optimal though not really sure about the speeds, as I'm running this program in a company with alot of servers dealing with loads of jobs a day :) Pe単a, Botp wrote: > From: Clement Ow [mailto:clement.ow@asia.bnpparibas.com] > # $options= > you may remove the "$" sign ;) i use the "$" sign because I have a config file that holds all my values, but I didnt include it for the purpose of this example ;) > > > # U:/movtest/source > # U:/movtest/new > # U:/movtest/new1] > # > # $dest= > # %w[U:/test_1/ > # U:/dest1/ > # U:/dest2/ > # U:/dest3/ > # U:/dest4/] > # > # while i<=j && i1<=j1 && i2<=j2 > > hmmm, you just created 3 parallel arrays. Either you can create one > multi-dimensional or a hash. > > > # Dir.chdir($source[i]) > > you may not need this > > # print "\nSource: " + Dir.getwd + "\t\n" > # print "Dest: " + $dest[i1] + "\n" > # print "Options: " + $options[i2] +"\n" > # FileUtils.cp_r Dir.glob($options[i2]), $dest[i1] > # print "File Mov Test:Success" > # i+=1 > # i1+=1 > # i2+=1 > > if you modify your code, you may not need those increments ;) > > # end > # ------------------ > # Apparently, when moving large files (i.e file size 50mb) it takes > # relatively long as when i use ROBOCOPY (a robust copying software by > # MSServer), > > robocopy seems to do stat on the filetransfer speed to get the optimum > chunk to transfer. You can do something like that in ruby, but you'll > have to work harder (since your code/logic will get a bit longer) > > # but I cant use robocopy because it has it's limitations > > it's not perfect, and w ruby, you can beat it :) yea, limitations being that I cant have exceptions while selecting a serious of folders. EG. I wanna select files and folders that start with 2008 but I want to keep the last day of the month untouched.(still yet to figure out this part though) > > So, if i were to tackle this, i'd first do, (note, this is ruby > pseudocode, ergo untested since i do not have time and space to test it > now...) > > > 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*", "700*", "2008*", "2008*"] > > # here i combine those 3 arrays into 1 multi-dim array > sd_a=source.zip(dest,options) hmmm, would combining the arrays be feasible if i were to add on more values to the either of the arrays? > > sd_a.each do |sd| > source, destination, selections = sd > src = File.join source,selections > puts "Source: #{src}" > puts "Dest: #{destination}" > > # i comment the 2 lines below for you to choose bw recurse or not > # again, if you recurse, check for directory overlaps > > # FileUtils.cp src, destination > # FileUtils.cp_r src, destination This command runs an error because the value of src is "C:/movtest/test/2008*" and it doesnt recognise this wildcard but instead looks for the file which has the name 2008*. so i tried to chang it alil: Dir.chdir(source) FileUtils.cp_r Dir.glob('2008*'), source, destination But still runs an error here showing : Source: C:/movtest/testing/2008* Dest: U:/test_1/ C:/movtest/testing c:/ruby/lib/ruby/1.8/fileutils.rb:1438:in `delete': can't convert Symbol into St ring (TypeError) from c:/ruby/lib/ruby/1.8/fileutils.rb:1438:in `fu_check_options' from c:/ruby/lib/ruby/1.8/fileutils.rb:1437:in `each' from c:/ruby/lib/ruby/1.8/fileutils.rb:1437:in `fu_check_options' from c:/ruby/lib/ruby/1.8/fileutils.rb:418:in `cp_r' from testing.rb:44 from testing.rb:32:in `each' from testing.rb:32 I have tried ways and means to try correct it but to no avail. Is there anything majorly wrong with my code? -- Posted via http://www.ruby-forum.com/.