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!
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 ]
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.
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.
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
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