Batch Files: Isolating a Unique Line


Honestly, this is basic use of the FIND command. There are no tricks. The goal here is to separate a single line in a file or command output by finding something different about it. Using FIND, that line can then be singled out. For example, in the DIR command, the line which contains the total size of all files contains the word "file(s)":
9 file(s) 173,558 bytes
A command such as
DIR | FIND "file(s)"
would extract that single line. Sometimes it may be necessary to string FINDs together. Some miscreant might create a file with the name "file(s)", and that would mess you up. Adding a reverse search for ":" would eliminate files from consideration (assuming your DIR output lists file creation times):
DIR | FIND "file(s)" | FIND /V ":"
Separating out just a single line gives you the most flexibility.

Lost? Look at the site map.

Bad links? Questions? Send me mail.

Google
Yahoo
Ask Jeeves