Wednesday, April 11, 2007

Multi Variable Batch

This is a great example for reading lines through a regular batch file and processing the input at tokens.

Lets say for example you have a file with the following input:

user1 homedir1
user1 homedir2


etc

If you want to, you could add this to your batch file;

for /f "tokens=1*" %%i in (filename.txt) do @echo %%j\%%i


Notice that %%j was not defined, but is automatically assigned a value alphabetically. The output will look something like;

homedir1\user1
homedir2\user2

No comments: