After I sent this I regretted it. I should try to work this out on my own. Stuart On 7/1/06, Dark Ambient <sambient / gmail.com> wrote: > Recently I asked here about where "end" goes, in relation to code > blocks. I was given some good answers which helped but now either I'm > having a same / similar problem or this is perhaps something > completely different. > > What I'm attempting to do in the code below is > 1-Search a directory for files > 2-Check if the files exist > 3-Ask user to confirm if they want file to be moved > 4-If user answers no , then file is removed from array. > 5-After user has gone through the entire list one by one, then the > updated array should list out the files (minus the ones that said no > to move on. > > Right now, the problem is step five (listing the updated array) is > happening with each question. Plus it looks like the elements are not > being removed where appropriate. Please let me know if I ask too many > questions here :). > > Dir.chdir 'C:/PicturesMoved' > > # First we find all of the pictures to be moved. > pic_names = Dir['C:/PicturesMoved/*.{BMP,bmp}'] > > pic_names.each do |name| > fcheck = FileTest.exist?(name) > if fcheck == true > puts 'Do you wish to move ' + name + 'file?' > puts 'Please answer "yes" or "no" ' > else puts 'file does not exist' > > end > end > > > > response = true > while (response) > decision = gets.chomp.downcase > if decision == 'yes' > response = false > else > puts 'File will not be moved' > pic_names.delete(name) > end > end > > > puts 'these files will be moved' > pic_names.each do |name| > puts name > > end > > p.s. The code is indented in my email here , hopefully it remains > formatted as such when it hits the list. > >