From: Peter Bailey Date: 2006-04-20T23:42:25+09:00 Subject: Questions about copying using FileUtils Hello, Can someone please help me with the following script? It doesn't work, and yields the message below this script. My "puts" is just for testing, to see if it sees the files. The "puts" works fine when I don't include the copy line just below it. I'm just copying original files to files of the same name, with different extensions. I could as well be opening new files of these new names, not just copying them. As a related question, do all iterators, like my "each" below, require an "end?" Thanks a lot. ______________________________________________________________________________ Dir.chdir("c:/scripts/ruby/temp") require 'fileutils' include FileUtils::Verbose psfiles = Dir.glob('*.ps') psfiles.collect!{ |psfile| File.basename(psfile, '.ps') } psfiles.each do |psfile| puts psfile FileUtils.cp("psfile", psfile + ".pageinfo") end ------------------------------------------------------------------------------- gives me this . . . test1 c:/ruby/lib/ruby/1.8/fileutils.rb:1182:in `stat': No such file or directory - ps file (Errno::ENOENT) from c:/ruby/lib/ruby/1.8/fileutils.rb:1182:in `lstat' from c:/ruby/lib/ruby/1.8/fileutils.rb:1160:in `stat' from c:/ruby/lib/ruby/1.8/fileutils.rb:1242:in `copy_file' from c:/ruby/lib/ruby/1.8/fileutils.rb:459:in `copy_file' from c:/ruby/lib/ruby/1.8/fileutils.rb:383:in `cp' from c:/ruby/lib/ruby/1.8/fileutils.rb:1377:in `fu_each_src_dest' from c:/ruby/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest0' from c:/ruby/lib/ruby/1.8/fileutils.rb:1375:in `fu_each_src_dest' from c:/ruby/lib/ruby/1.8/fileutils.rb:382:in `cp' from c:/scripts/ruby/images/check_indexes.rb:10 from c:/scripts/ruby/images/check_indexes.rb:8 -------------------------------------------------------------------------------- -- Posted via http://www.ruby-forum.com/.