From: Peter Bailey Date: 2007-07-26T21:21:49+09:00 Subject: Re: Boolean question. File here but not there. Peter Hickman wrote: > Peter Bailey wrote: >> Thanks, >> > What is this line for? The only reason that tiffile has a value is that > the Dir.glob("*.tif") returned a filename proving the existence of the > tif file, Dir.glob() is not going to return the names of non existent > files or are you expecting the file to disappear? If so you have other > problems. > > Also if pdfdir is a copy of tifdir you should probably just find a > better name for the variable and simplify some more. There is quite a > bit of superfluous code here and it will only serve to confuse you at a > later date when you come back to it and ask yourself "Why did I do > that?" > > Try this simple rewrite: > > list.each do |dir| > Dir.chdir("L:/tiff/cdtiff/#{dir}") > Dir.glob("*.tif").each do |tiffile| > pdffile = File.basename(tiffile, ".tif") + ".pdf" > pdfthere = File.exists?("L:/pdf/single/#{dir}/#{pdffile}") > if ! pdfthere > File.open("E:/logs/pdfnotthere.txt", "a") { |f| f.print > "#{dir}/#{pdffile} not there\n" } > end > end > end I don't know exactly what line you're referring to, Peter. But, your suggestions are good ones. I like the "pdfthere" with the ! coming later, instead of my "pdfnotthere." Thanks a lot for your help. I'm playing with a combo of both yours and John's suggestions above. -- Posted via http://www.ruby-forum.com/.