From: "Mark J. Reed" Date: 2004-04-10T01:29:17+09:00 Subject: Re: File.rename weirdness (was Re: need help with recursion) "David A. Black" writes: >Hi -- >On Sat, 10 Apr 2004, Robert Klemme wrote: > $ ls u_score/ > u_file > $ ruby -e 'File.rename("u_score/u_s", "u_score/u s")' > -e:1:in `rename': No such file or directory - > u_score/u_s or u_score/u s (Errno::ENOENT) > from -e:1 That's because the filename is "u_file", not "u_s". >I have to admit I have no idea why that happens or even what the error >exactly means. (What's with the "or"?) The error means simply that some file or directory, which the system needed to access in order to perform the rename, doesn't exist. The "or" inside the error message is there because the error can refer to either a file or directory. The "or" between the pathnames is there because the error might occur while processing either argument to rename: the source or the destination. Obviously, if the destination file doesn't exist, that's not an error, because it's not supposed to exist until after the rename. But if the destination is a pathname instead of just a bare filename, then one or more of the subdirectories on the way to the destination might not exist, and that would trigger the same error. For instance, if you'd done this: $ ruby -e 'File.rename("u_score/u_file", "u score/u_file")' that would fail with a very similar error because the directory "u score" doesn't exist. (You could, of course, rename the directory itself: $ ruby -e 'File.rename("u_score", "u score"); That would work fine.) -Mark