Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 将多个目录中的文件内容复制到一个文件中_Batch File - Fatal编程技术网

Batch file 将多个目录中的文件内容复制到一个文件中

Batch file 将多个目录中的文件内容复制到一个文件中,batch-file,Batch File,我正在尝试将不同目录中具有相同名称的多个文件复制到一个文件中 A:/D/D01/a small file.txt A:/D/D02/a small file.txt A:/D/D03/a small file.txt A:/D/D04/a small file.txt -------------------------- A:/D/D09/a small file.txt 我正在尝试将所有“a small file.txt”文件复制到另一个文件a:/D/new.txt 我正在命令提示符中尝试此

我正在尝试将不同目录中具有相同名称的多个文件复制到一个文件中

A:/D/D01/a small file.txt
A:/D/D02/a small file.txt
A:/D/D03/a small file.txt
A:/D/D04/a small file.txt
--------------------------
A:/D/D09/a small file.txt
我正在尝试将所有“a small file.txt”文件复制到另一个文件a:/D/new.txt

我正在命令提示符中尝试此操作

A:\D>copy D*\"a small file.txt" new.txt
但每次我都会收到一条错误消息:

**The filename, directory name, or volume label syntax is incorrect.**

请注意,某些目录不包含该文件。

复制命令无法执行您想要执行的操作。这里有一种方法

这将使用
FOR
命令在命令
DIR a:\D\a small file.txt”/s/b返回的文件路径列表中循环。对于列表中的每个文件路径,
TYPE
命令列出使用
输出重定向器重定向到文件
new.txt
的内容

FOR /F "delims= usebackq" %%f IN (`DIR "A:\D\a small file.txt" /s /b`) DO TYPE %%f>>A:\D\new.txt