首页 > 解决方案 > Windows 10,xcopy 失败

问题描述

我有一个传输文件结构的python脚本,在python脚本中它使用for循环遍历文件和文件夹,下面是它尝试执行的指令的典型示例:

$ xcopy ../../Core/Service\ Groups/Core_Build/Windows\ 10\ x86\ (1) ../../Core/Releases/Windows\ 10\ x86\ (1)/Windows\ 10\ x86\ (1a) /f /e /y

这在 bash 脚本中执行并导致:

bash: syntax error near unexpected token `('

我看不出该命令有什么问题,所有空格都已转义,我删除了路径周围的引号,因为这会导致不同的错误。

源路径确实存在,并且我已经验证了两种情况下的相对引用都是正确的。

如果我尝试:

$ xcopy /f /e /y "../../Core/Service Groups/Core_Build/Windows 10 x86 (1)" "../../Core/Releases/Windows 10 x86 (1)/Windows 10 x86 (1a)/"

我得到:

Invalid number of parameters

标签: windows-10xcopy

解决方案


  1. 如果路径包含空格和其他特殊字符,则必须将路径放在引号中。
  2. 将您的源和目标放在命令的开头:
xcopy "../../Core/Service Groups/Core_Build/Windows 10 x86 (1)" "../../Core/Releases/Windows 10 x86 (1)/Windows 10 x86 (1a)/" /fey

推荐阅读