Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
54 user(s) are online (31 user(s) are browsing Forums)

Members: 1
Guests: 53

samo79, more...

Headlines

Report message:*
 

Re: Looping in DOS batch scripts

Subject: Re: Looping in DOS batch scripts
by jPV on 2021/5/24 17:12:59

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 filethen 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!


Powered by XOOPS 2.0 © 2001-2016 The XOOPS Project