Copying folders but not files with Robocopy

by Mitch Tulloch [Published on 21 June 2012 / Last Updated on 26 Jan. 2012]

A tip on how you can copy folders but not files using Robocopy

Let's say you have a folder C:\dir1 and within \dir1 you have some files and some folders.  You want to copy the folders but not the files to a different directoy C:\dir2.  How can you do this using Robocopy?

You can do it like this:

for /f "delims=" %f in ('dir/b/ad C:\dir1') do robocopy /e C:\source\%f C:\dir2\%f

Mitch Tulloch is a seven-time recipient of the Microsoft Most Valuable Professional (MVP) award and widely recognized expert on Windows administration, deployment and virtualization. For more tips by Mitch you can follow him on Twitter or friend him on Facebook.

The Author — Mitch Tulloch

Mitch Tulloch is a widely recognized expert on Windows administration, networking, and security. He has been repeatedly awarded Most Valuable Professional (MVP) status by Microsoft for his outstanding contributions in supporting users who deploy and use Microsoft platforms, products and solutions. Mitch has published over two hundred articles on different IT websites and magazines, and he has written or contributed to almost two dozen books and is lead author for the Windows 7 Resource Kit from Microsoft Press. For more information, see .

Latest Contributions

Featured Links