cmd - Loop over an interval of files -



cmd - Loop over an interval of files -

i define for-loop (windows command line) iterates on (numbered) intervals of files in directory, 1..100, , 101..200, , 201..300 etc [edit: regardless of files names]. see next pseudo-code:

for %workdir% %%f(1..100) in (*.htm) ( rem dosomething %%f ) %workdir% %%f(101..200) in (*.htm) ( rem dosomething %%f ) ...etc

q: there way define "numbered intervals" of files command line?

// rolf

you can place each function in separate file:

:1to100 setlocal enabledelayedexpansion set /a "file=1" rem skip 0 (skip=0 omitted because it's illegal) , process 100. /f %%f in ('dir %workdir%\*.htm /b') ( if !file! gtr 100 (exit /b) else (set /a "file+=1") echo %%f. ) endlocal goto :eof :100to200 setlocal enabledelayedexpansion set /a "file=1" rem skip 100 , process 100. /f "skip=100" %%f in ('dir %workdir%\*.htm /b') ( if !file! gtr 100 (exit /b) else (set /a "file+=1") echo %%f. ) endlocal goto :eof

cmd

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -