批处理文件注释不一致

时间:2012-10-26 22:40:32

标签: windows batch-file comments

我注意到有时当我在批处理脚本中添加注释时,我会收到错误:

The syntax of the command is incorrect.

其他时候,没有问题。在它运作的情况下我看不到任何模式,而不是它没有的情况。

例如:

for /R /D %%d in (.\*) do (

    echo %%d
    :: comment here  <<NO ERROR>>

    for %%f in (%%d\*) do (

        echo %%f
        :: comment here <<ERROR>>
    ) 
)

最高评论没有问题,底部评论没有问题。两者都在他们自己的行上,完全相同的文本,选项卡,并在echo语句后直接。第一条评论没问题,第二条评论会导致错误。

为什么?

1 个答案:

答案 0 :(得分:2)

如果您使用REM代替::它适合您...

可能是解析器错误: - )

for /R /D %%d in (.\*) do (

    echo %%d
    REM comment here  <<NO ERROR>>

    for %%f in (%%d\*) do (

        echo %%f
        REM comment here <<ERROR>>
    ) 
)
相关问题