如何使用 Windows shell 从其他 Windows 树创建 fake/dummy Windows 树?
How to create a fake/dummy Windows tree from other Windows tree with Windows shell?
我有一个很大的 Windows 目录和文件树。现在我需要将这棵树复制到另一个位置,但我不想复制每个文件的内容。只需要内容为 0 字节的结构和文件名。如何使用 as cmd shell in Windows 10?
我做了什么:
xcopy /t e:\oldtreedir e:\new\oldtreedir
dir /a /b /s > mybat.bat
将 mybat.bat 编辑为:
replace \ne:\ to
\ncopy nul e:\new\
所以对于每个文件名,行
copy nul e:\new\oldtreedir\file1.txt
我不得不编辑 mybat.bat。这可以通过 Windows 命令行中的脚本来完成吗?
PS:我发现了这个:WIN-PRg 但是这个程序没有创建目录树。所有文件仅在一个目录中。
无需创建额外的批处理文件:
@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!"
)
如果我答对了你的问题,robocopy
应该可以解决问题:
robocopy "E:\oldtreedir" "E:\new\oldtreedir" "*.*" /E /CREATE
我有一个很大的 Windows 目录和文件树。现在我需要将这棵树复制到另一个位置,但我不想复制每个文件的内容。只需要内容为 0 字节的结构和文件名。如何使用 as cmd shell in Windows 10?
我做了什么:
xcopy /t e:\oldtreedir e:\new\oldtreedir
dir /a /b /s > mybat.bat
将 mybat.bat 编辑为:
replace \ne:\ to \ncopy nul e:\new\
所以对于每个文件名,行
copy nul e:\new\oldtreedir\file1.txt
我不得不编辑 mybat.bat。这可以通过 Windows 命令行中的脚本来完成吗?
PS:我发现了这个:WIN-PRg 但是这个程序没有创建目录树。所有文件仅在一个目录中。
无需创建额外的批处理文件:
@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!"
)
如果我答对了你的问题,robocopy
应该可以解决问题:
robocopy "E:\oldtreedir" "E:\new\oldtreedir" "*.*" /E /CREATE