gpt4 book ai didi

windows - 批处理 : "usebackq" not expected at this time

转载 作者:可可西里 更新时间:2023-11-01 11:24:54 25 4
gpt4 key购买 nike

我有这个代码:

setlocal enableextensions
for "usebackq" %%i in (`dir /b`) do echo * %%i
endlocal

我想做的很简单:打印带有 * 前缀的当前目录的内容。像这样:

* .idlerc 
* .oracle_jre_usage
* .swt
* Searches
* Contacts
* Downloads
* My Directory
* Documents
* Desktop
* Favorites
* Images
* Saved Games
* Music
* 3D Objects

但是,当执行时,它说:

"usebackq" not expected at this time

我是 Batch 中的 for 语句的新手。有人可以帮忙吗?

最佳答案

使用FOR /F并且您不需要在此处的选项中使用引号*,因为其中没有空格:

setlocal enableextensions
FOR /F usebackq %%i IN (`DIR /B`) DO ECHO * %%i
endlocal

*虽然保留引号不会造成任何伤害

关于windows - 批处理 : "usebackq" not expected at this time,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41060170/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com