From: 7stud -- Date: 2007-10-27T07:33:25+09:00 Subject: Re: Problem using FileUtils to sort JPEG files > It makes a > bit more sense to me to check to make sure the dir exist > while looking through everything Consider this: how does ruby determine if a filename is a directory? Suppose your directory has 2,000 files in it. Next, suppose you ask ruby if "my_file.jpg" is a directory. What if ruby first has to look at each and every one of those 2,000 files to look for a match with filename? Then if it found a match, ruby had to look at the stats for the file to determine if it's a directory. That would mean that every time you ask if a filename is a directory, ruby has to step through every one of those 2,000 files to look for a match. Do you think that is very efficient? > > I added in the rescue > block the same as you have, and it still exists the loop when run over > the script itself. > I have no idea what that means. If you are asking how to determine what error to catch with the rescue statement, do this: remove the rescue statement from your code and try to read a file that RMagick doesn't recognize, and then examine the error message. The error message will give the name of the error. For instance, if you run this program: puts x the error message is: "undefined local variable or method `x' for main:Object (NameError)" To handle that error, you can write: begin puts x rescue NameError puts "caught the error" end -- Posted via http://www.ruby-forum.com/.