Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.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
Windows 用不同目录中的文件替换子目录中的多个文件_Windows_Batch File_Replace_Cmd - Fatal编程技术网

Windows 用不同目录中的文件替换子目录中的多个文件

Windows 用不同目录中的文件替换子目录中的多个文件,windows,batch-file,replace,cmd,Windows,Batch File,Replace,Cmd,我想从一个目录中获取一个名为test1.hfl的文件,并替换我的c驱动器中运行的文件夹子目录中的所有现有test1.hfl文件 我已使用以下代码启动批处理文件: FOR /R C:\Users\----\Documents\Train\Runs\ %%I IN (*test1.hfl) DO COPY /Y C:\Users\----\Documents\test1.hfl %%~fI 但它不起作用 如果您发现问题,请告诉我。试试这个: cd /d "C:\Users\----\Documen

我想从一个目录中获取一个名为
test1.hfl
的文件,并替换我的c驱动器中运行的文件夹子目录中的所有现有
test1.hfl
文件

我已使用以下代码启动批处理文件:

FOR /R C:\Users\----\Documents\Train\Runs\ %%I IN (*test1.hfl) DO COPY /Y C:\Users\----\Documents\test1.hfl %%~fI
但它不起作用

如果您发现问题,请告诉我。

试试这个:

cd /d "C:\Users\----\Documents\Train\Runs"
FOR /D /R \ %%a IN (*) do if exist "%%~a\test1.hfl" echo copy /y "test1.hfl" "%%~a"
查看输出并删除单词
echo
,如果它看起来不错


谢谢,但我只想将其复制到已包含该文件的文件夹中。好的,请立即尝试。在上面的代码中,它如何知道哪个是新的test1.hfl文件以及从何处获取该文件?我的新test1.hfl文件位于文件夹C:\Users\----\Documents\中,但它确实可以工作。谢谢抱歉,这有点过早-它说系统找不到指定的文件代码从当前文件夹中获取文件。当前文件夹设置为
cd/d“C:\Users\---\Documents\Train\Runs”
。如果出现消息
file not found
,则文件夹设置错误(即没有这样的文件)。