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

Using Android Volley to post an array to PHP -

python - How to add an model instance to a django queryset? -

angularjs - No 'Access-Control-Allow-Origin' error from local domain to public API -