From: Stuart Clarke Date: 2010-09-06T23:47:06+09:00 Subject: Re: Slow Find.find - real problem Robert Klemme wrote: > On 04.09.2010 13:24, Stuart Clarke wrote: > >> 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. > >> 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? > > Brian gave excellent advice already. I'd just want to point out that > keeping hundred thousands of files in a single directory (do you?) is > generally slow on most file systems. If possible distributing them > across several directories generally helps speed up things. > > Kind regards > > robert I agree, Brian gave some great code and the speed increase was very impressive so many thanks. The final block of code is given below. Regarding the large number of files in a directory, I agree its tough on the file system, however that is our of my control. pdfFiles = "\\data" Find.find(pdfFiles) do |curPath| oldID = File.basename(curPath) newID = nameMap[oldID] next unless newID File.rename(curPath.to_s.strip, "#{@pdfFiles}\\#{newID}.pdf") end Many thanks again -- Posted via http://www.ruby-forum.com/.