From: "Hal E. Fulton" Date: 2002-08-31T13:59:51+09:00 Subject: Re: HT copy a directory structure, and all files to a single directory... ----- Original Message ----- From: "Kurt Euler" To: "ruby-talk ML" Sent: Friday, August 30, 2002 11:42 PM Subject: HT copy a directory structure, and all files to a single directory... > Recently Matz and others advised the code below for recursively reading file names in a directory structure. (It works fine.) > > Follow up questions: > > -- How can I expand this (or use related) code to copy the directory structure and files to a parallel directory where the target directories aren't already there. (Eg, recreate the whole structure in "../dupe_structure".) > > -- A slightly different objective here: Assuming all files in the directories have unique names, how can I copy all files to a single target directory. (It seems to me this would involve parsing f somehow to extract just the file name. In the code below, f includes the path too.) Some hints: 1. File.basename will extract the filename 2. File.dirname will extract the directory 3. If you use the ftools library, there is a makepath (or something?) that will do the equivalent of mkdir -p on UNIX. Of course, if you make them only one level at a time, Dir.mkdir will probably be sufficient. Hal