Run many commands in a loop, inserting a counter variable with sfk runloop for Windows, Mac OS X and Linux (free open source).
sfk runloop ifrom ito "your command $[digits]i" [-yes] [-nohead] sfk runloop ifrom -steps=n [-inc=i] "your command $[digits]i"sfk printloop ifrom ito "your text $[digits]i"
run a self-defined command many times, or simply print text to
the console, with a counter starting at ifrom, running until ito,
or running n times if -steps=n is specified.
with runloop, execution of commands is just simulated by default,
so nothing happens. as soon as your command is looking well, add
option "-yes" to really execute.
-inc=i increment step counter by i instead of 1.
-spat support slashpatterns like \t \q \xnn.
-delay=n wait n msec after every executed command.
-nohead does not display the [simulating:] info text.
printloop is the same as runloop -nohead.
-quiet does not echo the commands before execution.
-quietrc do not print rc status message per command.
command string format
the command string may contain $i which is replaced by the
loop counter, or slashpatterns if option -spat is given.
due to syntax limitations of the command shell, it may help
- to use \q instead of \" (avoids quote miscounting at shell)
- to use \x26 instead of & (if ampersand is behaving unexpected)
$i also supports format parameters before 'i' like:
$5i print 5 digits, right justified, filled with blanks.
$05i print 5 digits, right justified, filled with zeros.
$-5i print 5 digits, left justified, filled with blanks.
to print the $ char itself in output use $$
quoted multi line parameters are supported in scripts
using parm trim. type "sfk script" for details.
aliasessfk printloop do not execute anything but just print
the resulting text to terminal.
see alsosfk run - run self-defined command on filenames.
web referencehttp://stahlworks.com/sfk-runloopexamplessfk runloop 1 100 "copy mytest.dat testfile_$03i.dat" -yes
creates 100 copies of mytest.dat named testfile_001.dat,
testfile_002.dat, testfile_003.dat etc.
sfk printloop 1 100 -spat "<a href=\qhttp://...&page=$i\q>$i</a>"
creates html code containing 100 web links. note that \q was used
instead of \", as '&' may create problems when combined with \"
(a syntax mess produced by the command shell, not by sfk itself.)
and to enable slash patterns like \q, -spat had to be added.