Tech Tips / Windows NT / Tools and Tasks

Using the FOR command for repetitive tasks

You can use the Windows NT command shell's FOR command for numerous repetitive tasks, from creating a directory on every one of your Windows NT servers to simple housekeeping. Let's look at a fairly simple application of the FOR command's text-parsing capability to perform some administrative tasks. To use FOR to parse text, use the syntax:

  FOR /F "tokens=T delims=D eol=E" %I in (Input File) do Command

The /F switch puts FOR in text-parsing mode. T is the token(s) that you want to read from each line of text. D is the delimiter used to separate tokens. E is the character used to mark the end of a line of text. The Input File is the name of the file that FOR parses, and Command is the command that FOR iterates. Seem complicated? You'll be typing FOR commands blindfolded before you know it, but for now you can learn best by example.

Contact Us | Authors | Subject Index | Directory | RSS Feeds

Copyright ©2006 Setup32.com