Computing.Net > Forums > Programming > Parsing Text files

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.

Parsing Text files

Reply to Message Icon

Name: MikeSwim07
Date: October 9, 2008 at 17:18:25 Pacific
OS: Windows XP Home
CPU/Ram: 512mb
Product: Dell
Comment:

Is there a standalone .exe that can parse a certain text file with another file.

Like I have 4 files,

Good.txt
Results.txt
standalone.exe
batchfile.bat

I run the batch file, it produces Results.txt, then further in the batch file it used standalone.exe to parse results.txt with the contents of good.txt


Or can I make a batch file to do it?

Example:

Results.txt

C:\test.txt
C:\test123.txt
C:\baddie.exe

Good.txt

C:\test.txt
C:\test123.txt

Parsing...

Results.txt after parsing

C:\baddie.exe




Sponsored Link
Ads by Google

Response Number 1
Name: Judago
Date: October 10, 2008 at 01:25:10 Pacific
Reply:

How exactly are the files to be parsed? Parsing basically means that something is to be done to it by some sort of rules, without telling us what the rules are we can only imagine.


0

Response Number 2
Name: pball
Date: October 10, 2008 at 06:52:24 Pacific
Reply:

I would guess from the example that anything that isn't in the good list but is in the results should be displayed in the results.

I actually just made a script for something that does almost or exactly this. Let me test it first then I'll post it.

EDIT

yup a quick change to a script i just made works nicely.
--
@echo off
setlocal EnableDelayedExpansion

set f1=H:\New Folder\results.txt
set f2=H:\New Folder\good.txt
set out=H:\New Folder\notgood.txt

for /f "usebackq tokens=*" %%a in ("%f1%") do (
set dif=2
for /f "usebackq tokens=*" %%b in ("%f2%") do (
if %%a==%%b set dif=1
)
if !dif!==2 echo %%a >> "%out%"
)
pause
----------------------

set f1 to your results file
set f2 to your good file
set out to the parsed file name you would like

I can't think of a simple solution to just write the results to the result.txt file.

If you have both files and the batch script in one folder can just use the names where they are set and not the whole path.


0

Response Number 3
Name: MikeSwim07
Date: October 10, 2008 at 15:22:14 Pacific
Reply:

Ok I think it works but after is parses, it says

ECHO is off.

where I told it to do this in the original batch file

echo. >> "%cd%"\SCKStemp.txt

Also there seems to be a problem with the echoing to a file with >>. Instead, the thing I wanted to be echoed it displayed on the command prompt.


0

Response Number 4
Name: pball
Date: October 10, 2008 at 16:14:33 Pacific
Reply:

where in the script did you add that line.

if you can tell me that i might be able to help some.


0

Response Number 5
Name: MikeSwim07
Date: October 10, 2008 at 16:15:52 Pacific
Reply:

It's before the parsing thing that you made me.


0

Related Posts

See More



Response Number 6
Name: pball
Date: October 11, 2008 at 14:23:48 Pacific
Reply:

i do not know what is wrong. I tried what you posted and it created the file with a space in it.


0

Response Number 7
Name: MikeSwim07
Date: October 11, 2008 at 15:32:48 Pacific
Reply:

What should I do?


0

Response Number 8
Name: Judago
Date: October 11, 2008 at 16:48:44 Pacific
Reply:

Post a clear and detailed description on what your are trying to achieve and what problem you are stuck on along with any other relevant information, this is by far the fastest and most effective way to ask help.


0

Response Number 9
Name: MikeSwim07
Date: October 11, 2008 at 17:15:37 Pacific
Reply:

For some reason this batch,

FOR %%G IN (
abc
123
tree
) DO (
dir C:\*.* /L /A /B /S|Find "%%G" >> "%cd%"\SCKStemp.txt
)
If not exist "%cd%"\SCKStemp.txt echo "Files not found" >> "%cd%"\SCKStemp.txt
start notepad "%cd%"\SCKStemp.txt
exit

Brings up:

"Access is Denied" when it tried to open up the text file at the end. Why?


0

Response Number 10
Name: Judago
Date: October 11, 2008 at 17:40:39 Pacific
Reply:

Because you have quotes on the directory with the file name after it.

This should fix it:


If not exist "%cd%\SCKStemp.txt" echo "Files not found" >> "%cd%\SCKStemp.txt"
start notepad "%cd%\SCKStemp.txt"

You should also be able to get away with just specifying the file name because the current directory will be assumed:


If not exist SCKStemp.txt echo "Files not found" >> SCKStemp.txt
start notepad SCKStemp.txt


0

Response Number 11
Name: MikeSwim07
Date: October 11, 2008 at 17:47:02 Pacific
Reply:

I Went into the command prompt and tried this,

C:\>"%cd%"\wizard.txt

C:\>"%cd%\wizard.txt"

and they both worked. So why do I have to do the second one?


0

Response Number 12
Name: Judago
Date: October 11, 2008 at 18:05:49 Pacific
Reply:

[edit: I was wrong, it was start and not notepad]

Because start won't tolerate it, technically double quotes are illegal characters in file and folder names. For example if cd were the %userprofile% on xp (c:\documents and settings\<user>) then "%cd%"\SCKStemp.txt would expand to "c:\documents and settings\<user>"\SCKStemp.txt.

Start only seems to accept what's inside the quotes as a file name because it's more strict about the illegal character. Notepad obviously can't open directories, if you try it gives the "access denied" message and starts a new "untitled" document. Because your only supplying a directory name within the qoutes notepad is saying "I can't open a directory". You will get the same message for "start notepad c:".


0

Response Number 13
Name: MikeSwim07
Date: October 12, 2008 at 04:35:13 Pacific
Reply:

I got it,

Thanks

I went through all of my scripts and changed where the quotes are.


0

Response Number 14
Name: pball
Date: October 12, 2008 at 07:43:46 Pacific
Reply:

well i'm glad someone could step in and fix that other problem


0

Sponsored Link
Ads by Google
Reply to Message Icon






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: Parsing Text files

vbscript to parse text file and com www.computing.net/answers/programming/vbscript-to-parse-text-file-and-com/16691.html

batch file to parse text file www.computing.net/answers/programming/batch-file-to-parse-text-file/18030.html

batch script to parse text file www.computing.net/answers/programming/batch-script-to-parse-text-file/16793.html