Computing.Net > Forums > Programming > Finding a line in text file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Finding a line in text file

Reply to Message Icon

Name: x2aberry
Date: June 12, 2009 at 13:26:40 Pacific
OS: Windows XP
CPU/Ram: 2g
Subcategory: Batch
Comment:

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?




Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: June 12, 2009 at 14:15:14 Pacific
Reply:

If you want full lines with //

find "//" < myfile


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

M2


0

Response Number 2
Name: x2aberry
Date: June 15, 2009 at 07:55:25 Pacific
Reply:

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


0

Response Number 3
Name: Mechanix2Go
Date: June 15, 2009 at 09:42:50 Pacific
Reply:

@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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Finding a line in text file

Batch search multiple lines in text file. www.computing.net/answers/programming/batch-search-multiple-lines-in-text-file/18768.html

passing a value to text file www.computing.net/answers/programming/passing-a-value-to-text-file-/18831.html

finding last lines of text file www.computing.net/answers/programming/finding-last-lines-of-text-file/8807.html