From: Berger, Daniel [mailto:djberge@qwest.com]
That means there was something wrong with your choice of file names
because File.move in ftools.rb attempts to call ‘rename’ first. Only if
that fails does it resort to readlink. My guess would be that either
‘old’ does not exist, or that you forgot to include a double backslash
inside double quotes, e.g. “C:\temp1” vs “C:\temp1”.
FileTest.exist?(old) #> true
I’m using forward slashes, instead of escaped backslashes as that seems to
work well for the rest of the file stuff. (I’ve tried it with double
backslashes anyway, but it made no difference).
You can avoid ftools or fileutils altogether and simply use File.rename.
Just tested it on my Windows XP box and it works fine.
I actually tried File.rename(old, newdir) and it kind of worked if I did it
on its own. However, when I tried this:
File.open(file).readlines.each do | line |
#do stuff
end
File.rename(old, newdir)
I got permission denied. ‘file’, is located in ‘old’ so if it wasn’t closed
then that would make sense. I initially read that File.open automatically
closed itself at the end, but re-reading I now see that’s only if you give
it a block.
Doh! … so finally, this worked:
f = File.open(file)
f.readlines.each do | line |
#do stuff
end
f.close
File.rename(olddir, newdir)
···
-----Original Message-----