single line for statement: %%i 'unexpected at this time'

寵の児 提交于 2020-01-20 17:15:38

问题


for /r %%i in (*) do (echo %%i)

Results in

%%i was unexpected at this time

Why?


回答1:


You must be trying to run the command from the command line and not from within a batch file. Use a single % instead of two when running from the command line.

for /r %i in (*) do (echo %i)

Type HELP FOR from the command line and read the 3rd paragraph.




回答2:


Syntax:

FOR /R [[drive:]path] %%parameter IN (set) DO command

Need the path before %%i... which is why it's Unexpected

If you want to do * for current directory, just use ".\" for the path

for /r ".\" %%i in (*) do (echo %%i)


来源:https://stackoverflow.com/questions/8898088/single-line-for-statement-i-unexpected-at-this-time

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!