Computing.Net > Forums > Windows XP > Batch File reading a 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.

Batch File reading a Text File

Reply to Message Icon

Name: thegrantguy
Date: July 18, 2006 at 02:30:05 Pacific
OS: XPSP2
CPU/Ram: CeleronR 2.93GHz, 512 MB
Product: Dell Dimension DIM3000
Comment:

Hello All! I have a formatted text file that I wish to read with a batch file for further processing. It is formatted like so:
o,object1.sql
r,report1.xml
r,report2.xml
b,table1.sql . . .
and so on, where the first character is a code which tells what kind of file it is (since some of them have the same file extensions) followed by a (,) delimiter, and the file name. I am trying to write a batch that goes through the whole file and completes the commands for each file. Here is my code:

for /f "delims=," %%a in (testing.txt) do (
if %%a==o goto OBJECTS
if %%a==r goto REPORTS
if %%a==b goto TABLES
)
:OBJECTS
for /f "tokens=2 delims=," %%b in (testing.txt) do echo.This is where further commands will go on %%b
goto EOF

and so on... for each type of file.
My problem is, when a match is found in the first for command, it goes to the correct section, but then it does the command for all files in testing.txt, not just the one found.
How can I get it to go through all the files, and do the neccessary command on each depending on their code? ANY help on this would be GREATLY appreciated as I have been working on this for some time now. Thank you all in advance.
Cheers,
tgg

help. me.



Sponsored Link
Ads by Google

Response Number 1
Name: thegrantguy
Date: July 18, 2006 at 02:43:04 Pacific
Reply:

I moved this to the programming section... don't know how to delete the original :(

help. me.


0

Response Number 2
Name: mattie
Date: July 18, 2006 at 02:54:12 Pacific
Reply:

wait til 'the man comes around' :-)

Today's subliminal thought is: 'Calm down ... it's only ones and zeros.'

icq 10183575


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 Windows XP Forum Home


Sponsored links

Ads by Google


Results for: Batch File reading a Text File

problem -Batch file for taking text www.computing.net/answers/windows-xp/problem-batch-file-for-taking-text/168243.html

Batch file parsing a text file www.computing.net/answers/windows-xp/batch-file-parsing-a-text-file/174226.html

Batch file to edit text file www.computing.net/answers/windows-xp/batch-file-to-edit-text-file/156973.html