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-06-21 05:34
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » (Solved) How to hide the results displayed during the for search file process View 2,035 Replies 23
Original Poster Posted 2007-10-10 13:17 ·  中国 河北 保定 联通
初级用户
Credits 114
Posts 49
Joined 2006-10-08 06:47
19-year member
UID 64907
Status Offline
This code displays messages like "Device not ready", "File not found" when running. How to hide these messages? I added >NUL in several places but got errors.

for %%a in (Z Y X W V U T S R Q P O N M L K J I H G F E D C) do for /f "delims=" %%b in ('dir /s/b/a %%a:\AVP.EXE 2^>NUL') do if exist "%%b" set xt=%%a:
for /f "usebackq delims=/" %%i in (`dir /s/a-d/b %xt%\AVP.EXE 2^>NUL`) do set aa_dir=%%~dpi
cd /d %aa_dir%


[ Last edited by bd540 on 2007-10-11 at 02:28 AM ]
Floor 2 Posted 2007-10-10 13:40 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
Floor 3 Posted 2007-10-10 13:57 ·  中国 河北 保定 联通
初级用户
Credits 114
Posts 49
Joined 2006-10-08 06:47
19-year member
UID 64907
Status Offline
Originally posted by wudixin96 at 2007-10-10 13:40:
2>nul

Thanks, please tell me where to specifically add it?
Floor 4 Posted 2007-10-10 14:23 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
Floor 5 Posted 2007-10-10 14:37 ·  中国 河北 保定 联通
初级用户
Credits 114
Posts 49
Joined 2006-10-08 06:47
19-year member
UID 64907
Status Offline
Originally posted by wudixin96 at 2007-10-10 14:23:
Where is the dir

It doesn't work. Can you help post the modified one? Thanks a lot.
Floor 6 Posted 2007-10-10 14:44 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
Is your purpose to find the directory where avp.exe is located and then switch to that directory? Right?
Floor 7 Posted 2007-10-10 14:59 ·  中国 河北 保定 联通
初级用户
Credits 114
Posts 49
Joined 2006-10-08 06:47
19-year member
UID 64907
Status Offline
Floor 8 Posted 2007-10-10 15:12 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
@echo off
for %%a in (Z Y X W V U T S R Q P O N M L K J I H G F E D C) do (
dir /a /b /s "%%a:\avp.exe">nul 2>nul
if not errorlevel 1 for /f "delims=" %%i in ('dir /a /b /s "%%a:\avp.exe"') do start "" "%%~dpi"
)
pause

What does this mean?
Floor 9 Posted 2007-10-10 15:31 ·  中国 河北 保定 联通
初级用户
Credits 114
Posts 49
Joined 2006-10-08 06:47
19-year member
UID 64907
Status Offline
Originally posted by wudixin96 at 2007-10-10 15:12:
@echo off
for %%a in (Z Y X W V U T S R Q P O N M L K J I H G F E D C) do (
dir /a /b /s "%%a:\avp.exe">nul 2>nul
if not errorlevel 1 for /f "delims=" %%i in ('dir ...

Thanks, OK.
Floor 10 Posted 2007-10-10 15:40 ·  中国 河北 保定 联通
初级用户
Credits 114
Posts 49
Joined 2006-10-08 06:47
19-year member
UID 64907
Status Offline
There is another question. Your command opens all the files found by the search. How to open only the first one found by the search?
Floor 11 Posted 2007-10-10 15:44 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
Then find the first one, start it, and then exit.
Floor 12 Posted 2007-10-10 16:49 ·  中国 河北 保定 联通
初级用户
Credits 114
Posts 49
Joined 2006-10-08 06:47
19-year member
UID 64907
Status Offline
Originally posted by wudixin96 at 2007-10-10 15:44:
Then just find the first one, start it, and then exit.

Can GOTO be used?
Floor 13 Posted 2007-10-10 17:26 ·  中国 河北 保定 联通
初级用户
Credits 114
Posts 49
Joined 2006-10-08 06:47
19-year member
UID 64907
Status Offline
Originally posted by wudixin96 at 2007-10-10 15:44:
Then just find the first one, start it, and exit.

Can't handle it, looking forward to a reply.
Floor 14 Posted 2007-10-10 17:51 ·  中国 天津 电信
银牌会员
★★★
Credits 1,928
Posts 931
Joined 2007-01-06 11:46
19-year member
UID 75624
Gender Male
Status Offline
How did you write it?
Floor 15 Posted 2007-10-10 17:56 ·  中国 河北 保定 联通
初级用户
Credits 114
Posts 49
Joined 2006-10-08 06:47
19-year member
UID 64907
Status Offline
Originally posted by wudixin96 at 2007-10-10 17:51:
How did you write it??

:P I'm not very familiar with DOS, and I'm not familiar with some basic commands. The above code was still pieced together by searching the forum, so please give me the complete command :D
Forum Jump: