批处理文件复制脚本

时间:2016-08-09 18:12:22

标签: batch-file

我经常发现自己需要从多个服务器复制文件。我一直在为每个副本创建一个关闭脚本,但我想创建一个提示输入的基本脚本,以便我使用的其他人也可以使用它们。我无法让它发挥作用。

Echo
set /p sourcepath= What is the source file path? [Full UNC Path]
set /p destinationpath= What is the destination directory? {FQDN}\[path]
set /p targetspath= Where is the targets file?
FOR /f "delims=" %%i IN ("%targetspath%") DO (xcopy "%sourcepath%" "\\"%%i"\%destinationpath%")
pause

我试过移动引号arround但没有运气我一直收到文件未找到错误或cmd窗口刚刚关闭才能看到发生的事情(尽管暂停)

1 个答案:

答案 0 :(得分:0)

尝试一下:

Echo+
set /p sourcepath= What is the source file path? [Full UNC Path]
set /p destinationpath= What is the destination directory? {FQDN}\[path]
set /p targetspath= Where is the targets file?
FOR /f "delims=" %%i IN ("%targetspath%") DO (xcopy "%sourcepath%" "\\%%i\%destinationpath%")
pause>nul