我的目录结构如下所示;
folder1
folder2 (thousands of folders like this)
folder3
someImage.jpeg
someDoc.doc
folder4 (optional folder)
someImage.jpeg
someDoc.doc
我希望脚本复制包含文件夹4s的文件夹2s,维护文件夹结构,但只复制文件夹4中的文件。像这样;
folder1
folder2 (thousands of folders like this)
folder3
folder4 (optional folder)
someImage.jpeg
someDoc.doc
我有一个简单的for循环,可以识别包含文件夹4的文件夹,然后将文件Robocopy到某个目录。我无法弄清楚如何在文件夹3中跳过文件时复制整个文件夹结构。
答案 0 :(得分:3)
xcopy
命令中有一个选项可以创建目录树。
/T Creates directory structure, but does not copy files. Does not
include empty directories or subdirectories. /T /E includes
empty directories and subdirectories.
先做,然后只复制文件夹4s中的文件。
答案 1 :(得分:1)
@echo off
for /d %%a in (*.*) do (
echo %%a
for /d %%b in (%%a\*.*) do (
echo %%b
for /d %%c in (%%b\*.*) do (
echo %%c
for /d %%d in (%%c\*.*) do (
echo %%d
for %%f in (%%d\*.*) do (
echo %%f
)
)
)
)
)