Batch file 我需要帮助将文件复制到目录中的所有文件夹
我需要能够将“C:\Some Directory”中的file.txt复制到“C:\Some Other Directory”中的每个文件夹 到目前为止,我已经提出了以下代码: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\%
@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
在代码中的任何地方都不存在。