使用文件复制文件夹和子文件夹,但使用Windows命令行跳过根文件夹中的文件

问题描述 投票:-1回答:1

如何跳过根文件夹中的文件,但复制子文件夹及其文件。

windows cmd
1个回答
0
投票

命令行。更改f:\1在您选择的文件夹中启动它。

for /f "tokens=*" %a in ('dir /b /ad') do @%windir%\System32\xcopy /is "%a" "f:\1\%a"

批量。更改f:\1在您选择的文件夹中启动它。

for /f "tokens=*" %%a in ('dir /b /ad') do @%windir%\System32\xcopy /is "%%a" "f:\1\%%a"

捷径。更改f:\1在您选择的文件夹中启动它。

%windir%\System32\cmd.exe /c for /f "tokens=*" %a in ('dir /b /ad') do @%windir%\System32\xcopy /is "%a" "f:\1\%a"

对于%a只在目录名称的目录列表中(dir /b /ad)xcopy %a +子目录和xcopy没有询问%a是一个文件还是一个目录,如果xcopy多个文件(xcopy /is "%a")。您不必将xcopy写入不同的驱动器(即xcopy /is "%a" "backup\%a"),但它必须是您不想复制的目录。双引号处理路径/文件名中的空格。

求助:

xcopy /?

dir /?

for /?

© www.soinside.com 2019 - 2024. All rights reserved.