作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有这个代码:
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/
我有一个运行得很愉快的批处理文件,直到最后几次运行,但现在不是。违规代码如下: set uncommittedchanges=1 for /f "tokens=* usebackq" %%a in (
我有这个代码: setlocal enableextensions for "usebackq" %%i in (`dir /b`) do echo * %%i endlocal 我想做的很简单:打印
批处理脚本非常新。我需要将命令的输出分配给变量。我了解了 FOR/F 命令。我的命令有空格和双引号。所以我尝试使用 usebackq 选项。但它因空间错误而失败。 for /F "usebackq d
我想读取一个包含多个(未终止的)Kafka 主机的字符串,并使用 cmd for 将它们列出在单独的行中。 字符串如下: host1:9092,host2:9092,host3:9092,... 我所
我是一名优秀的程序员,十分优秀!