windows 重命名文件时出现“命令的语法不正确”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20105735/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 11:06:44  来源:igfitidea点击:

Error "The syntax of the command is incorrect" when renaming a file

windowsbatch-filecommand-line

提问by user2821300

I get this error on this step of my SQL 2005 process:

我在 SQL 2005 过程的这一步收到此错误:

rename "G:\AuthorsList\AuthorsList_New.mdb""G:\AuthorsList\AuthorsListCopy.mdb"

I am trying to rename the file. I have also tried this and get the same error:

我正在尝试重命名文件。我也试过这个并得到同样的错误:

rename "G:\AuthorsList\AuthorsList_New.mdb" "G:\AuthorsList\AuthorsListCopy.mdb"

How do I resolve this error?

如何解决此错误?

回答by Marek Grzenkowicz

Check the documentation for the renamecommand:

检查重命名命令的文档:

Syntax
rename [Drive:][Path]filename1 filename2

Parameters
[Drive:][Path]filename1: Specifies the location and name of the file or set of files you want to rename. FileName1 can include wildcard characters (* and ?).
filename2: Specifies the new name for the file. You can use wildcard characters to specify new names for multiple files.

句法
rename [Drive:][Path]filename1 filename2

参数
[Drive:][Path]filename1:指定要重命名的文件或文件集的位置和名称。FileName1 可以包含通配符(* 和 ?)。
filename2: 指定文件的新名称。您可以使用通配符为多个文件指定新名称。

The second parameter cannot be a path, it should contain only the new filename:

第二个参数不能是路径,它应该只包含新文件名:

rename "G:\AuthorsList\AuthorsList_New.mdb" AuthorsListCopy.mdb