On Jul 3, 2006, at 14:59, Dark Ambient wrote: > I 'suspected' this as I had a similar issue (different behaviour) in > my last previous thread. > > What I had to do to correct things is if 'yes', push into the new > array AND still delete from former array, and if 'no', just delete > from former/existing array. Weird I think(?) especially in regards to > the 'no', but without the delete, it continues to loop on the gets. > Reposting my code just to show what I've changed. Things are working > correctly not (until at least I add the next function :)). Thank you > for the help! Not to be negative, but I don't think things are actually working, at least not the way you think they should be. It seems to me that there's no reason you should have to delete entries from the pics2bmoved array in this code, unless pics2bmoved has incorrect data in it to begin with. For example, the following initial conditions give you similar behaviour to what you describe, and would be 'fixed' using delete, since that deletes all of the duplicate entries, but the *real* bug would be in the code which creates pics2bmoved: destdir = ["/foo/a.txt", "/foo/b.txt"] pics2bmoved = ["/bar/a.txt", "/bar/a.txt", "/bar/a.txt", "/bar/ b.txt", "/bar/b.txt", "/bar/b.txt"] So, basically, I have a *very* strong hunch that the bug you're seeing here actually exists somewhere else and that you're curing the symptom and not the disease. You should be able to confirm this by checking the state of the pics2bmoved variable before starting the loop, possibly as follows: destdir = Dir['C:/testfilesmoved/*.*'] newmove = [] puts pics2bmoved # ADDED THIS destdir.each do |name| pics2bmoved.each do |x| [...] end end This is part of a two-part general strategy that will really help you when you're learning to program. The first part is to work out what you *think* should be happening all the way through the code. The second part is to confirm that it's *actually* happening the way you think. Using 'puts' as above is the dead-simple way to do it, which lets you manually check that what's going on matches what you expect. There are various ways to automate this sort of checking, but doing it manually is probably best at first. Following on from previous questions of yours, I'll also point out that you've got the ends of the if statements mislabelled again. Remember, the first one started is the *last* one ended. You've got the loops right, though. matthew smillie.