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-09 12:03
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] How do I run other *.bat files on drive A:? View 824 Replies 5
Original Poster Posted 2008-08-09 09:37 ·  中国 河北 唐山 联通
新手上路
Credits 10
Posts 4
Joined 2008-08-06 06:56
18-year member
UID 122791
Gender Male
From 河北省唐山市丰润县
Status Offline
How do I run other *.bat files on drive A:?
Give me an example to teach me, okay, everyone who sees this post
And also tell me how I can quickly find posts I've edited myself, thanks

[ Last edited by beautifulfairy on 2008-8-9 at 09:50 AM ]
Floor 2 Posted 2008-08-09 10:55 ·  中国 江苏 苏州 吴江区 电信
银牌会员
★★★
Credits 1,608
Posts 780
Joined 2007-10-07 10:19
18-year member
UID 99089
Gender Male
Status Offline
The name of your own batch file is %~nx0. If you use a for loop, you can do it like this
for /f "delims=" %%i in ('dir/a-d/b *.bat') do (
if not "%%i"=="%~nx0" echo %%i
)
This filters out running your own program.
As for the second question, ask a moderator.
Floor 3 Posted 2008-08-09 20:00 ·  中国 湖北 武汉 联通
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Floor 4 Posted 2008-08-10 08:18 ·  中国 河北 唐山 联通
新手上路
Credits 10
Posts 4
Joined 2008-08-06 06:56
18-year member
UID 122791
Gender Male
From 河北省唐山市丰润县
Status Offline
Originally posted by huahua0919 at 2008-8-9 10:55:
The name of your own batch file is %~nx0. If you use a for loop, you can do it like this
for /f "delims=" %%i in ('dir/a-d/b *.bat') do (
if not "%%i"=="%~nx0" echo %%i
)
So it filters ...

What I mean is how to run it, using call, start, or something like that.
Floor 5 Posted 2008-08-10 08:32 ·  中国 广东 广州 天河区 电信
银牌会员
★★★★
SuperCleaner
Credits 2,362
Posts 1,133
Joined 2008-02-02 21:36
18-year member
UID 110072
Gender Male
Status Offline
Then just modify it yourself... change echo to Call or Start.
I think the answer in reply #2 is perfect, because this is how you said it: “other *.bat files”
What's even more汗 is... you yourself already know about using Call start and so on... and you're still asking
Floor 6 Posted 2008-08-10 10:40 ·  中国 广东 广州 电信
银牌会员
★★★
永远的菜鸟
Credits 1,335
Posts 574
Joined 2007-11-27 12:50
18-year member
UID 103929
Gender Male
From 广西
Status Offline
Make it a bit smarter:
@echo off
setlocal enabledelayedexpansion
for /f "delims=" %%a in ('dir /s/b/a-d a:\*.bat') do (
set /a "n+=1"
set "fairy!n!=%%a"
echo !n! "%%a"
)
:again
set "input=0"
echo.&echo Press Enter to exit directly, or enter the file number and press Enter to run it
set /p input=Please choose:
if /i "%input%"=="0" goto :eof
start "" "!fairy%input%!"
goto :again
Forum Jump: