From: "Jesús Gabriel y Galán" Date: 2010-09-04T22:17:02+09:00 Subject: Re: Slow Find.find - real problem On Sat, Sep 4, 2010 at 2:10 PM, Stuart Clarke wrote: > Thanks for getting back to me. At present I read the CSV file get the > first line of information the. Search the file system in the object > above. > > Are you saying I should hash the file system, loop through the hash and > get the first entry then search the csv and rename? > > Could you provide an example please? The basenames are all unique! If you are starting with a unique basename, and then traversing your folders to find it, and those folders have a lot of files, then you will be traversing your folders many times, when you can probably cache the structure in memory. That's what Brian was proposing. So you could start with reading all the folders and files and mapping each basename to its full path in a hash: require 'find' h = {} Find.find "/home/jesus/ruby" do |file| h[File.basename(file)] = file end and then, read each line of the CSV file and search for the basename in the hash: CSV.foreach("files.csv") do |old,new| if h[old] #rename h[old] to new end end Hope this helps, Jesus.