Stuart Clarke wrote:
> 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?

The slow bit will be scanning the filesystem.

I suggest you run a single File.find across the whole tree, building a 
suitable data structure (e.g. a hash of {basename => full filename} for 
every file which is eligible to be renamed)

Then when you read in the CSV, you can just cross-reference to this data 
structure and locate the files immediately.

If there is a possibility of more than one file with the same basename 
existing in multiple directories, then build your data structure 
appropriately, e.g.
{basename => [fullpath1, fullpath2, fullpath3, ...]}

Alternatively, do this the other way round: read in the whole CSV (which 
is likely to be fast) into a suitable data structure, and then scan 
across the filesystem once; while you scan it, for every file you find 
check whether the CSV had a rename instruction for it.

If the CSV is too big to fit into memory then consider loading it into a 
database of some sort instead.

HTH,

Brian.
-- 
Posted via http://www.ruby-forum.com/.