Copy a Directory Tree "Flat" – all files into one folder, no subfolders

Let’s say you have exported all families in a Revit project to a bunch of folders by Category, but you want to get them all into one folder so you can drag-drop and load them all into a new project all at once…

Copy the following into a batch file:

@echo off
set source=”E:tempEexport”
set destination=”E:tempEexport2″

::Not sure if this is needed
::It guarantees you have a canonical path (standard form)
for %%F in (%destination%) do set destination=”%%~fF”

for /r %source% %%F in (.) do if “%%~fF” neq %destination% ROBOCOPY “%%F” %destination% *.rfa /COPYALL /R:0

Now, change the text in red to suit your source and destination (my destination folder was empty).  Run the batch file and you should have a stack of RFAs all sitting in that folder.  Note: results may be a bit unpredictable if you have duplicates of particular files in the source directory tree.

Read more:
file – ROBOCOPY – Copy folders content to a single folder – Stack Overflow

Leave a Reply

4 Comment threads
0 Thread replies
Most reacted comment
Hottest comment thread
1 Comment authors
Sam William Recent comment authors
newest oldest most voted
Notify of
Alfredo Medina

When we use the built-in tool "Save as… Library" > Families… the result is that all the families are saved into the same folder, without subfolders. What would be the difference in the result if somebody uses this routine?

Alfredo Medina

The bult-in tool for saving the project as library already puts all the families in one single folder. What would be the advantage of using this routine?

Luke Johnson

I had used the Case exporter, and it puts families into folders by category.

Sam William

Hello there,
Your post contains lots of valuable information. I used the Case exporter, and by category, it puts families in folders. Thanks for the post.