相关疑难解决方法(0)

关于Windows批处理文件的奇怪问题

我的工作目录中有1.txt2.txt.我使用以下批处理列出所有文件.

批次是这样的:

@echo off
for /f "tokens=*" %%a in ('dir *.txt /b') do (
    echo ---------------
    set file_variable=%%a
    echo file_variable=%file_variable%
    echo filename=%%a
    )    
Run Code Online (Sandbox Code Playgroud)

结果如下:

---------------
file_variable=2.txt   <---------------why it is not 1.txt here??
filename=1.txt
---------------
file_variable=2.txt
filename=2.txt
Run Code Online (Sandbox Code Playgroud)

谢谢.

scripting cmd batch-file

2
推荐指数
1
解决办法
5746
查看次数

标签 统计

batch-file ×1

cmd ×1

scripting ×1