Just wanted to finish the thread off here by saying I finally have
working code, accomplishing my task of utilizing File.exists? and
eliminating my loop issues. For the sake of my own
self-aggrandizement I'll post the code (open to criticism or comment)
Dir.chdir 'C:/testfilesmoved'
require 'ftools'
pic_names = Dir['C:/testfilesorig/*.*']
destdir = Dir['C:/testfilesmoved/*.*']
pics2bmoved = []
pic_names.each do |name|
puts 'Do you wish to move ' + name + 'file?,"yes" or "no" ?'
decision = gets.chomp.downcase
if decision == 'yes'
if destdir.empty?
pics2bmoved.push(name)
else
if File.exists?(destdir[name.to_i]) == false
pics2bmoved.push(name)
else
puts name + ' already exists in destination,
overwrite? "yes" or "no" '
ow = gets.chomp.downcase
if ow == 'yes'
pics2bmoved.push(name)
else
puts 'This ' + name + ' will not be moved'
end # ow == yes
end # File.exists?
end # destdir.empty?
end # decision == yes
end # for pic_names loop
if pics2bmoved.empty?
puts
puts 'No files will be moved'
else
puts
puts 'These files will be moved'
puts pics2bmoved
end