Tutorial by Examples

The following will echo each line in the file C:\scripts\testFile.txt. Blank lines will not be processed. for /F "tokens=*" %%A in (C:\scripts\testFile.txt) do ( echo %%A rem do other stuff here ) More advanced example shows, how derived in FOR loop from a restricted files set...
for /r command can be used to recursively visit all the directories in a directory tree and perform a command. @echo off rem start at the top of the tree to visit and loop though each directory for /r %%a in (.) do ( rem enter the directory pushd %%a echo In directory: cd rem leave...
The following uses a variable with a for loop to rename a group of files. SetLocal EnableDelayedExpansion for %%j in (*.*) do ( set filename=%%~nj set filename=!filename:old=new! set filename=Prefix !filename! set filename=!filename! Suffix ren "%%j" "!filename!%%~x...
for /L %%A in (1,2,40) do echo %%A This line will iterate from 1 to 39, increasing by 2 each time. The first parameter, 1, is the starting number. The second parameter, 2, is the increment. The third parameter, 40, is the maximum.

Page 1 of 1