RTV Tools

Saturday, April 12, 2014

Copy a Directory Tree to a single Folder (copy flat) with this script

Have you ever wanted to copy a directory tree of family files to a single directory? Once you do this, you can load them all into a Revit instance in a single "Load Family" operation - just go to the directory and then Ctrl+A to select all, then click Open.

The following script will copy a directory tree to a single directory - essentially discarding the directory structure. It also filters by file type and only includes RFA files. Copy the code to Notepad, save as CMD or BAT.

dir "sourcedirectory" /A:D /B /S > tempListOfDirs.txt
For /F "tokens=*" %%A IN (tempListOfDirs.txt) Do (
If Exist %%A* (
XCOPY "%%A\*.rfa" "targetdirectory" /Y /R
del tempListOfDirs.txt

Once you have a single directory of RFA files and have loaded them all into Revit, you could then use the categorizer to sort them all into directories by Category... its really an automated and free way to upgrade and sort your family library.

Note: I had previously posted a similar script using Robocopy at

What Revit Wants: Copy a Directory Tree "Flat" - all files into one folder, no subfolders

This code modified from:

Commerce Server Guy: Tree-To-Flat Copy Using XCopy

No comments:

Post a Comment