Reputation: 1341
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:
xcopy /t e:\oldtreedir e:\new\oldtreedir
dir /a /b /s > mybat.bat
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.
Upvotes: 0
Views: 987
Reputation: 34919
If I got your question right, robocopy
should do the trick:
robocopy "E:\oldtreedir" "E:\new\oldtreedir" "*.*" /E /CREATE
Upvotes: 3
Reputation: 56180
No need to create an additonal batch file:
@echo off
setlocal enabledelayedexpansion
xcopy /t e:\oldtreedir e:\new\oldtreedir
for /f %%a in ('dir /b /s /a-d "e:\oldtreedir\*"') do (
set "file=%%a"
set "file=!file:E:\=E:\new\!"
break>"!file!"
)
Upvotes: 1