Who's Online |
52 user(s) are online ( 38 user(s) are browsing Forums)
Members: 0
Guests: 52
more...
|
|
Headlines |
-
kittymusicraft.library.lha - development/library
Aug 8, 2022
-
arabic_console_devicepro2.lha - driver/input
Aug 8, 2022
-
amiarcadia.lha - emulation/gamesystem
Aug 8, 2022
-
amosextension.library.lha - library/misc
Aug 8, 2022
-
luettjebookholler.lha - office/misc
Aug 6, 2022
-
mce.lha - game/utility
Aug 5, 2022
-
ign-addon-ods.lha - office/spreadsheet
Aug 5, 2022
-
avalanche_deu.lha - utility/archive
Aug 4, 2022
-
mednafen.lha - emulation/gamesystem
Aug 3, 2022
-
avalanche.lha - utility/archive
Aug 3, 2022
|
|
|
|
Looping in DOS batch scripts
|
Posted on: 2021/5/23 10:12
#1
|
Home away from home 
Joined: 2006/11/26 21:45 Last Login
: Yesterday 21:20
From a dying planet
Group:
Registered Users
|
Hey, a question to all the DOS batch experts. I'd like to create a looping batch script that does slightly different things (but effectively the same), but to different targets. I know how to do it in rexx, but i'm not firm enough to pull it off in .bat. Here's what i like to achieve (i have the loop figured out, but i don't know how to set up the target(s), so that the loop will read them one by one.
target="path1", "path2", "path3", "end"
LAB Main
if target EQ "end"
QUIT
endif
if target EQ "path1"
do stuff
endif
else
do other stuff
endif
SKIP BACK Main
Any help appreciated, thank you very much
|
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/23 10:41
#2
|
Home away from home 
Joined: 2006/11/20 16:26 Last Login
: Today 6:14
From Norway
Group:
Registered Users
|
@Raziel
MSDOS .bat files complete different, You might consider writing a py or ruby or vbs script, they are easier to write.
|
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/23 11:32
#3
|
Home away from home 
Joined: 2006/11/26 21:45 Last Login
: Yesterday 21:20
From a dying planet
Group:
Registered Users
|
@LiveForIt This is AmigaDOS 
|
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/23 12:14
#4
|
Home away from home 
Joined: 2006/11/20 16:26 Last Login
: Today 6:14
From Norway
Group:
Registered Users
|
@Raziel
AmigaDOS don’t use #?.bat as extension, only protection bit S for script.
Anyway, if you have directory with sub directories. You can use LIST command with LFORMAT, to generate a new script. for etch directory.
Anyway this can be easier in AREXX, way better for strings.
|
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/23 12:54
#5
|
Home away from home 
Joined: 2006/11/26 21:45 Last Login
: Yesterday 21:20
From a dying planet
Group:
Registered Users
|
@LiveForIt
Actually i've got it all figured out, the only thing missing is a way to give a variable with differing entries to the loop.
I know there is .KEY, but is there something like .KEY.1(.2,.3 etc.) That way i could simply enhance a counter (e.g. i=i+1) during the loop and simply ask for .KEY.i.
...
I know arexx is far better suited for this (that's why most of the work is done by an arexx script already). The problem is, that i need to be IN the directory when starting the arexx script, because arexx will only act on the directory it is started in, so i have to copy the rexx script to either directory and that is what i'd like to do in a batch loop.
Right now i mirrored four commands in the batch one after the other, each altering only in the path where the rexx script is copied to and started in.
There has to be a smarter way...
|
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/23 15:30
#6
|
Just popping in 
Joined: 2017/5/18 11:12 Last Login
: 6/23 22:06
From Audruicq, France
Group:
Registered Users
|
|
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/23 19:08
#7
|
Home away from home 
Joined: 2006/11/26 21:45 Last Login
: Yesterday 21:20
From a dying planet
Group:
Registered Users
|
@Petrol
Good call, exactly what i was looking for
Thanks a lot
|
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/23 23:09
#8
|
Just can't stay away 
Joined: 2006/12/1 18:01 Last Login
: Yesterday 23:09
From Copenhagen, Denmark
Group:
Registered Users
|
@Raziel Quote: The problem is, that i need to be IN the directory when starting the arexx script, because arexx will only act on the directory it is started in This sounds to me like a misunderstanding - although I am not quite sure what you're actually trying to do, once you know where to do it. You can always build a path in a string variable, even an absolute one, or a relative one starting with one or more '/' for that matter, and use that string variable to "address command 'cd ' || pathvar" or something, i.e. effectively set the current dir of your running script's process somewhere else. Normally it's good practice to save your current dir first, so you can restore it at the end of the script. Best regards, Niels
|
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/24 12:07
#9
|
Home away from home 
Joined: 2006/11/26 21:45 Last Login
: Yesterday 21:20
From a dying planet
Group:
Registered Users
|
@nbache I need to make a note of this, might actually save me the batch script...then again, it's down to some lines with foreach  But thank you for the suggestion, Niels
|
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/24 17:12
#10
|
Just popping in 
Joined: 2019/11/27 12:32 Last Login
: 8/1 15:27
From RNO
Group:
Registered Users
|
I once made a file size based counter ;) I don't know if there would be other way, but if you don't have the ForEach command (on OS3, for example), then you could hack it like this (modified it to do what you asked) :P
; some paths you want to handle
setenv 1 "RAM:"
setenv 2 "T:"
setenv 3 "SYS:"
; init our counter to zero
echo "" noline > ENV:counter
; loop start
lab loop
; increase counter by one
echo "" >> ENV:counter
; read the counter value to a local variable
set i `list env:counter lformat "%L"`
; if we have a corresponding file, then do stuff and loop
if exists env:$i
; Get contents
set p `getenv $i`
; Do stuff
echo "Processing $p"
if $p eq "SYS:"
echo " Special case!"
else
echo " Normal case..."
endif
; clear variables
unsetenv $i
unset p
; jump back in the script
skip loop back
endif
; otherwise clean up and quit
unsetenv counter
unset i
And that would output:
Processing RAM:
Normal case...
Processing T:
Normal case...
Processing SYS:
Special case!
|
|
|
|
Re: Looping in DOS batch scripts
|
Posted on: 2021/5/24 18:34
#11
|
Home away from home 
Joined: 2006/11/26 21:45 Last Login
: Yesterday 21:20
From a dying planet
Group:
Registered Users
|
@jPV Thank you, worth a peek 
|
People are dying. Entire ecosystems are collapsing. We are in the beginning of a mass extinction. And all you can talk about is money and fairytales of eternal economic growth. How dare you! – Greta Thunberg
|
|
Currently Active Users Viewing This Thread:
1
(
0 members
and 1 Anonymous Users
)
|
|
|