Batch file 将指定文件及其子文件夹复制到另一个文件夹[批处理]

Batch file 将指定文件及其子文件夹复制到另一个文件夹[批处理],batch-file,Batch File,这个问题与此相关:一点点 我有一个空文件夹和第二个文件夹,其中有另一个文件夹,其中有一些.class文件 Myfolder1\Folder1 - contains the class files Myfolder2\ - empty 我试过这个: set path=%%f (the variable from the last question) xcopy %path%\*.class Myfolder2\ /s 是这样的: xcopy Myfolder1\Folder1\

这个问题与此相关:一点点

我有一个空文件夹和第二个文件夹,其中有另一个文件夹,其中有一些.class文件

Myfolder1\Folder1 - contains the class files
Myfolder2\ - empty
我试过这个:

set path=%%f        (the variable from the last question) 
xcopy %path%\*.class Myfolder2\ /s
是这样的:

xcopy Myfolder1\Folder1\*.class Myfolder2\ /s
Myfolder2\Folder1\\[the class files]
需要将类文件复制到第二个文件夹(包括子文件夹)中,因此第二个文件夹应如下所示:

xcopy Myfolder1\Folder1\*.class Myfolder2\ /s
Myfolder2\Folder1\\[the class files]
有人知道吗?代码不需要使用Xcopy

感谢所有这些帮助。

这应该可以做到:

XCopy Myfolder1\*.class Myfolder2\ /S /I /Y
通过在父级Myfolder1上启动复制并指定/S开关,可以告诉命令在确定复制内容时查看子文件夹。在子文件夹中找到.class文件后,将在目标Myfolder2中创建相应的文件夹