Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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,我需要能够将“C:\Some Directory”中的file.txt复制到“C:\Some Other Directory”中的每个文件夹 到目前为止,我已经提出了以下代码: @echo off setlocal EnableDelayedExpansion Cd "C:\Some Other Directory" for /d /r %%G in (*) do ( Copy "C:\Some Directory\file.txt" "C:\Some Other Directory\%

我需要能够将“C:\Some Directory”中的file.txt复制到“C:\Some Other Directory”中的每个文件夹

到目前为止,我已经提出了以下代码:

@echo off
setlocal EnableDelayedExpansion
Cd "C:\Some Other Directory"
for /d /r %%G in (*) do (
    Copy "C:\Some Directory\file.txt" "C:\Some Other Directory\%%G"
)
但是,当我运行它时,它会为每个文件夹返回以下错误:

c:\Some Other Path\Folder
   0 file(s) copied
The filename, directory name, or volume label syntax is incorrect.
有什么想法吗

更新
Derp,我刚刚必须删除/r,它正在搜索不存在的文件。

%%G
将包含整个目标路径,因此
“C:\Some Other Directory\%%G”
将解析为
“C:\Some Other Directory\C:\Some Other Directory\a_subdirectory”

只需删除
C:\someotherdirectory\
前缀。

它显然不会返回该错误,因为
C:\someotherpath
在代码中的任何地方都不存在。