Search code examples
windowscmdcommand-linedirectory-structure

How to create a fake/dummy Windows tree from other Windows tree with Windows shell?


I have a big Windows directory and file tree. Now I need to copy this tree to another location but I do not want to copy the contents from each file. Only the structure and filenames with 0 bytes contents are needed. How could this be done with as cmd shell in Windows 10?

What I did:

  1. xcopy /t e:\oldtreedir e:\new\oldtreedir
  2. dir /a /b /s > mybat.bat
  3. edit mybat.bat to:

    replace \ne:\ to 
    \ncopy nul e:\new\
    

    so that it is for each filename the line

    copy nul e:\new\oldtreedir\file1.txt
    

I had to edit the mybat.bat. Could this be done by a script in the Windows command line?

PS: I found this: WIN-PRg but this program do not create a dir-tree. All files are in one dir only.


Solution

  • If I got your question right, robocopy should do the trick:

    robocopy "E:\oldtreedir" "E:\new\oldtreedir" "*.*" /E /CREATE