Greetings all,
I'm very new to Ruby but I'm enjoying what I've found so far. I'm
trying to write a little app to get myself started with Ruby. I want to
open a file which contains a list of filenames (each on a separate line)
and copy each file from the current directory, to another directory.
What I've tried is:
require 'ftools'
IO.foreach("dswFileList.txt") {|line| File.copy("line", "..\line") }
But that gives me an error in ftools.rb 'size' : No such file or
directory. I tried replacing "..\line" with "..\#{line}" and a few
other things, but I got the same error message.
Then I tried the following:
aFile = File.open("dswFileList.txt")
aFile.each do |file|
File.copy (file, '..\#{file}')
puts "Copied #{file}"
end
This gets me closer, however, it changes the filename to #{file}, but it
does put it in the proper directory.
I'd appreciate any help in straightening this out. Is there an easier
way to do this, or am I just screwing up my syntax.
Thanks!
Rob Thornton