Contents

Checking commandline arguments

if ""%1""=="""" goto usage

Checking if a file/dir exists

if not exist %1 goto invaliddir

Looping on all files in a directory

for /R %%f in (*.xml) do (
	set newfile=%%f
	set oldfile=!newfile:~0,-11!    
)

Substrings

REM cut the last 4 from the string
set oldfile=%newfile:~0,-4%

Using environment variables as real variables with late expansion

Remark: one should use !! instead of %%

setlocal ENABLEDELAYEDEXPANSION
set oldfile=blabla
set bakfile=!oldfile!.bak

Find IP Address

for /f "Tokens=2 Delims=[] skip=1" %%i in ('ping -n 1 %computername%') do set IP=%%i
-
- Views - Page - Discussion - View source - History -
- Personal tools - Log in -
- Special - Special pages -