Directory duplicating

2005/06/12 by Lassi A. Liikkanen

"Mirroring" Windows directory structures

A Windows/DOS batch for creating multiple directories at once.
If you wish to "mirror" a several Windows machines without doing it properly by using appropriate programs or can't get them networked, the next best thing to do is to establish a common scheme for creating directories between the computers.

Following examples has been tested and found working with Windows XP and 2000.

First, catch the existing directory structure from it's root:
dir /ad-h /b > dirs.txt

the /b parameter restrics the output to only directory names and /ad-h selects only non-hidden directories excluding many directories that e.g. Windows creates

The resulting file should look like this

Then transfer the dirs.txt file to the directory, under which you're duplicating the directories. E.g.:
move dirs.txt r:\Software\

Next thing to do is to create the directories based on the transfer file. This is most conveniently done with the for command as follows:
for /f %i in (dirs.txt) do @mkdir %i
Basically, it reads the file line by line and runs the mkdir command using each line's content as the parameter.

And finished! Next you can use any program that can detect differences between files to synchronize contents between the duplicated file systems. Note that in general you should find other means for keeping machines up to date, use this sort of an arrangement only as the final resort.

Related content:
How Windows 7 restore really works, 2014/04/26

Instructions for creating bootable Windows 7 recovery environment on a USB flash device, 2014/03/30

Disabling background software installations and upgrades in Windows, 2013/03/03

No comments for this page:
Add comment | Show all comments

Your email will not be shown publicly or disclosed to third parties, it is used to validate messages
Location (City, Country):
* This information must be provided

Keywords: [windows] , [computers] Document's status: Ok (Document dates explained)

This document created: 2005/06/12
Modified: 2005/06/12
Published: 2005/06/12

This document's permanent URI (linking):

© Lassi A. Liikkanen 2005 - 2021. All rights reserved.
^Top of the Page^

*Change layout:
Printable printable
Large text


@lassial Twitter feed: