Finding a line in text file

June 12, 2009 at 13:26:40
Specs: Windows XP, 2g
This is whats in the text file
-------------------------------------------------
Please Wait..........
CentralProfile REG_SZ
CentralProfile REG_SZ
CentralProfile REG_SZ \\ALPLCFP01\PROFILES$\MEBLINE.USR
CentralProfile REG_SZ \\ALXAPFS15\PROFILES$\X2ABERRY.USR
CentralProfile REG_SZ \\ALXAPFS17\PROFILES$\X2BJCUMM.USR
CentralProfile REG_SZ
Press any key to continue . . .
________________________________

I would like to go threw and pull out all of the paths(example:\\ALXAGFS17\PROFILES$\X2BJCUMM.USR) and compare each path to a user name (example:x2bjcumm)

If the path matches the username that I input, then that path is put into a variable. If it dosent match, move to the next path and check it.

......................
I've been trying to use this code
-------------------------
for /f "tokens=2 delims=//" %%c in (C:\profile.txt) do (
echo Retrieving %%c
pause
)
--------------------------------------------------
but it just returns the servername(example:ALXAGFS17) Not the entire line.


Any thoughts?



See More: Finding a line in text file

Report •


#1
June 12, 2009 at 14:15:14
If you want full lines with //

find "//" < myfile


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
June 15, 2009 at 07:55:25
Actually I would like to get everything after the \\
I was able to get the full line to print out but I cant seem to get just the patch ex:\\alxbhm\PROFILE$\bobdds.USR

Report •

#3
June 15, 2009 at 09:42:50
@echo off > newfile & setLocal enableDELAYedexpansion

for /f "tokens=* delims= " %%a in ('find "\\" ^< myfile') do (
for /f "tokens=1* delims=\\" %%i in ("%%a") do (
echo %%j >> newfile
)
)


=====================================
If at first you don't succeed, you're about average.

M2


Report •

Related Solutions


Ask Question