From: Dark Ambient Date: 2006-07-04T01:23:23+09:00 Subject: Re: if problem in loop causing weirdness On 7/3/06, Matthew Smillie wrote: > Hmm. This strikes me as a possible misunderstanding of how nested > loops work. The inner loop (pics2bmoved.each in this case) is > executed once for every element in the outer loop (destdir.each). In > a simpler example: > > a = ['a', 'b', 'c'] > b = [1, 2, 3] > a.each do |letter| > b.each do |number| > puts "#{letter}, #{number}" > end > end > > prints the following: > a, 1 > a, 2 > a, 3 > b, 1 > b, 2 > b, 3 > c, 1 > c, 2 > c, 3 Excellent illustration, very helpful , though the results are still forthcoming. > Which seems similar to what I guessed your problem might be. Are you > creating pics2bmoved in a similar sort of nested loop? pics2bmoved was created using just .push (which was the first section) However in section 2, it was the inner loop to the destination directory / or outer array. This would explain the repeating for the same element. I've gone ahead and am attempting to condense the two sections into one. I'm still faced with the same loop issues though for now. > Best of luck, > matthew smillie. Stuart