Limiting yourself to a .bat file complicates things. A language like vbscript or wcript supports substrings.
http://www.pctools.com/guides/scripting/ might be useful.
Kees
I am in need of help doing a FOR /F Do loop in a CMD Batch script.
I am trying to write a batch script that will ping all IP addresses in a host file except for an IP address taht starts with 127 and skip all commented lines in the hostfile or that start with a #.
my current code will ping the first word/string in every uncommented line, so I am halfway there. However I can't figure out how to compare the first 4 characters in the word/sting to 127. and have it skip it if starts with those characters.
Here is my working code. Any help will be appreciated.
[code]
@ECHO off
setlocal EnableExtensions EnableDelayedExpansion
DEL C:\temp\Pings.txt
ECHO. > C:\temp\Pings.txt
For /F "eol=# tokens=1" %%A in (c:\temp\TESThost) do ECHO PING -a "%%A" && ECHO. >> C:\temp\Pings.txt && ECHO. >> C:\temp\Pings.txt && ECHO PING -a "%%A" >> C:\temp\Pings.txt && PING -a "%%A" >> C:\temp\Pings.txt && ECHO ---------------------------------------------------------------- >> C:\temp\Pings.txt
[/code]

Chowhound
Comic Vine
GameFAQs
GameSpot
Giant Bomb
TechRepublic