![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-08-12 13:37 |
47,811 topics / 349,897 posts / today 0 new / 48,256 members |
| DOS批处理 & 脚本技术(批处理室) » What does this batch processing mean? for /f "usebackq tokens=1* |
| Printable Version 1,610 / 4 |
| Floor1 linuxzhen | Posted 2008-08-10 11:39 |
| 新手上路 Posts 2 Credits 8 | |
|
for /f "usebackq tokens=1* delims=/" %%a in (`dir /b "C:\pdf\"`)
Emergency help |
|
| Floor2 dosyenanjs | Posted 2008-08-10 11:42 |
| 初级用户 Posts 11 Credits 22 | |
|
Extract all columns of the entire row, ignoring spaces
|
|
| Floor3 haiou327 | Posted 2008-08-10 13:07 |
| 高级用户 Posts 348 Credits 713 | |
|
In the content output by set, use / as the delimiter, divide into two columns. Take the part to the left of the first / number as a segment to assign to %%a, and take the entire part starting from the right of the first / number as a segment to assign to %%b.
For example, the content of DIR is c:\pdf\1.txt c:\pdf\2.txt c:\pdf\3.rar c:\pdf\4.bmp Then use \ as the delimiter, c: c: c: c: The first column is assigned to %%a pdf\1.txt pdf\2.txt pdf\3.rar pdf\4.bmp All are assigned to %%b But the parameter you used here is DIR/B, which only outputs the file name, so tolens=1* delims=\ is redundant. Your sentence is standard. Just change it to the following: for /f "delims=*" %%a in ('dir /b d:\qq\') do ( echo %%a Combine with your above two examples and you can take a look The following is example 1 Example 2 [ Last edited by haiou327 on 2008-8-10 at 01:59 PM ] |
|
| Floor4 haiou327 | Posted 2008-08-10 13:09 |
| 高级用户 Posts 348 Credits 713 | |
|
```
for /f "usebackq tokens=1* delims=/" %%a in (`dir /b "C:\pdf\"`) do ( echo %%a ) ``` is equivalent to ``` for /f "tokens=1* delims=/" %%a in ('dir /b C:\pdf\') do ( echo %%a ) ``` If the path has no spaces, the tokens parameter can be omitted [ Last edited by haiou327 on 2008-8-10 at 01:57 PM ] |
|
| Floor5 zaixinxiangnian | Posted 2010-03-18 16:09 |
| 初级用户 Posts 106 Credits 151 From 河南省 | |
|
Still the enthusiasm here of ours,,, we are beginners and can't understand those two examples of yours. Can you explain them sentence by sentence? Thank you so much
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |