From: 7stud -- Date: 2007-10-29T14:54:31+09:00 Subject: Re: Problem using FileUtils to sort JPEG files Suppose your directory has 2,000 files in it. The way I see it, in order for your code to determine whether a file's type is already a directory, your code has to go searching through a directory with 2,000 files in it. And your code does that for each filename. Also, if your directory has 10,000 files instead of 2,000 files, then the search will take five times as long. The code I posted only has to search through the directory three times to set things up, i.e when it creates the directories. After that, the code loops over the file names and does a lookup in a hash to determine if there's a directory for the file's file type, and hash lookups are extremely fast. Which would you rather do: search a directory containing 2,000 files 2,000 times; or search a directory containing 2,000 files 3 times, and then do extremely fast hash lookups 2,000 times? For the purposes of the comparison, you can assume hash lookups take 0 time. -- Posted via http://www.ruby-forum.com/.