本文介绍了xcopy返回错误“参数数目无效".设置排除参数时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发出:

xcopy X:\ "Y:\...\bin\9876543210\" /c /g /d /i /e /r /h /y

按预期工作.但是:

xcopy X:\ "Y:\...\bin\9876543210\" /c /g /d /i /e /r /h /y /exclude:"Y:\...\exclude.txt"

返回错误:

当路径名(包含空格)没有用引号引起来时,也会发生这种情况.但是,事实并非如此.路径(已编辑,以提高可读性)均正确对应.语法(按照产品文档-Xcopy )也是正确的.关于操作系统,是Windows XP Professional x32 SP3.

Which also occurs when path names (containing spaces) are not enclosed by quotation marks. This however, is not the case. Paths (edited for readability) all correspond correctly. Syntax (as per Product Documentation - Xcopy) is also correct. Concerning OS is Windows XP Professional x32 SP3.

第二个cmd为什么返回错误,该如何解决?我不是在寻找xcopy的替代品(robocopy等).

Why is second cmd returning error and how is it to be solved? I am not looking for alternatives to xcopy (robocopy etc.).

推荐答案

XCOPY是一个古老的命令,可以追溯到DOS时代.似乎/EXCLUDE选项从未更新为支持长文件名. gh:-(

XCOPY is an old command harking back to the days of DOS. It looks like the /EXCLUDE option was never updated to support long file names. Ugh :-(

如果删除引号,则空格后的文本将被解释为附加参数,并且会出现参数数量无效"错误.如果保留引号,则它将引号视为路径的一部分,并报告找不到文件.

If you remove the quotes, then the text after the space is interpreted as an additional parameter, and you get the "Invalid number of parameters" error. If you keep the quotes, then it treats the quotes as part of the path, and reports it cannot find the file.

我相信您有三种可能的解决方案:

I believe you have three possible solutions:

1)在路径中使用简短的8.3文件夹名称.

当然,如果您的卷禁用了短名称,那么这将无法正常工作.

Of course this cannot work if your volume has short names disabled.

2)使用SUBST命令为麻烦的路径创建驱动器别名.

subst Q: "Y:\path with spaces"
xcopy X:\ "Y:\...\bin\9876543210\" /c /g /d /i /e /r /h /y /exclude:Q:exclude.txt
subst Q: /d

如果您不知道可用的驱动器盘符,可能会出现问题.

This could be a problem if you don't know a drive letter that is free.

3)(我的最爱),只需PUSHD即可完成麻烦的路径并从那里运行命令:-)

pushd "Y:\path with spaces"
xcopy X:\ "Y:\...\bin\9876543210\" /c /g /d /i /e /r /h /y /exclude:exclude.txt
popd



参见 https://sevenx7x .wordpress.com/2009/01/02/xcopy-with-exclude-option-shows-cant-read-file/ http://forums.majorgeeks.com/showthread.php?t=54300 了解更多信息.



See https://sevenx7x.wordpress.com/2009/01/02/xcopy-with-exclude-option-shows-cant-read-file/ and http://forums.majorgeeks.com/showthread.php?t=54300 for more information.

这篇关于xcopy返回错误“参数数目无效".设置排除参数时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 01:24