China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-12 14:20
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » Use a batch file to search for and open files under long directory names View 815 Replies 1
Original Poster Posted 2010-03-31 20:14 ·  中国 广西 百色 电信
中级用户
★★
Credits 265
Posts 92
Joined 2006-11-29 23:08
19-year member
UID 72114
Gender Male
From 广西
Status Offline
Hello everyone!
The environment is under cmd on an XP system. I use for /f %%i in ('dir/s/b/a-d c:\a.bat') do (start "" "%%i"), and under normal circumstances it works....


But when a.bat is on the desktop it won't open... I've searched the forum for a lot of related stuff, but still couldn't solve it myself. If anyone knows, please help. Thanks in advance!!

[ Last edited by uforange on 2010-3-31 at 20:17 ]
Floor 2 Posted 2010-03-31 21:03 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
for /f "delims=" %%i in ('dir/s/b/a-d c:\a.bat') do (start "" "%%i")

Don't make this kind of elementary mistake; it should be written like this

A few default values of for /f:
eol=c defaults to lines beginning with ;, and this is still the case even if eol= is not used
delims=xxx defaults to spaces and tabs, and this is still the case even if delims= is not used
tokens=x,y,m-n defaults to 1, and this is still the case even if tokens= is not used


for {%variable|%%variable} in (set) do command
No matter which form for uses, in (set) separation is done by spaces, tabs, English commas, and English semicolons (in for /f, only by spaces and tabs).


Because the first character of a local pathname cannot be ;, there is no need here to forcibly specify eol= as empty

[ Last edited by Hanyeguxing on 2010-3-31 at 21:22 ]
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
uforange +1 2010-04-05 13:12
Forum Jump: