From: Stuart Clarke Date: 2010-09-04T20:24:23+09:00 Subject: Slow Find.find - real problem Hey, I have a real head ache and would really appreciate any advice. I have a folder with 100,000's of files within it and I need to run a rename process across these. def renameFile(oldID, newID) Find.find(@pdfDIR) do |curItem| if File.file?(curItem) and curItem[/.pdf$/i] and File.basename(curItem)[/^T/i] #If the file is valid, is a PDF and it has not been renamed with T on the front else if File.basename(curItem.to_s.strip) == oldID File.rename(curItem.to_s.strip, "#{@pdfDIR }\\T#{newID}.pdf") #rename the exprted PDF file to the new filename with T on the front end end end end My main code basically reads the 2 pieces of data from a CSV file, first the current filename of the file and then the new filename I want to rename the file to. In summary, i grab the old and new filenames from a CSV file one at a time then call the above object where I search the given directory for a filename that matches the old file name, when I find it I rename it to the new name. My issue is this is very very slow and is taking about an hour to do 10 file renames. Is there any way I can speed this up? Many thanks Stuart -- Posted via http://www.ruby-forum.com/.