DosTips.com

A Forum all about DOS Batch
It is currently 20 Nov 2017 14:52

All times are UTC-06:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 09 Feb 2017 16:42 
Offline

Joined: 09 Feb 2017 16:21
Posts: 2
Hi guys, I am very new to batch codes and am self taught. I'm currently splitting a very large unique .txt file. I am outputting each unique type of data using the subsection code that is embedded into every line. I am currently using something along these lines to split each line into it's correct output .txt file.

Find string /r "^...."D currrent.txt >NAVAID.txt

From what I know this is searching for any string containing the 5th character "D" and outputting the whole line to a new .txt file called NAVAID.txt.

This is exactly what I need it to do. However, I have now run into a problem that I also need to put a similar line into another text file that looks for the 5th character to be D and the 6th B. They need to be seperate .txt files but every time I run the query it is seperacting the DB into its own file, but then selecting all the lines of text that start with D as a fifth character (including DB).

Find string /r "^...."D currrent.txt >NAVAID.txt
Find string /r "^...."DB currrent.txt >NAVAID.txt

How can I make it so that the line that references "D" will not include "DB"?

I hope that makes sense.

Thank you


Top
   
PostPosted: 09 Feb 2017 17:20 
Offline
Expert

Joined: 12 Feb 2011 21:02
Posts: 1953
Location: United States (east coast)
You cannot be using
Code: Select all
Find string /r "^...."D currrent.txt >NAVAID.txt

You must mean
Code: Select all
findstr /r "^...."D currrent.txt >NAVAID.txt


Assuming every D line has another character after it, then you could use something like the following:
Code: Select all
findstr /r "^....D[^B]" current.txt >NAVAID.txt
findstr /r "^....DB" current.txt >NAVAIDB.txt

If you have some D lines that don't have a 6th character, then
Code: Select all
findstr /r "^....D[^B] ^....D$" current.txt >NAVAID.txt
findstr /r "^....DB" current.txt >NAVAIDB.txt


Note - Please put code within code blocks. You can use the handy Code edit button at the top of the editor. The text should look like the following before you post:

[code]
Your code goes here
[/code]


Dave Benham


Top
   
PostPosted: 10 Feb 2017 00:42 
Offline

Joined: 09 Feb 2017 16:21
Posts: 2
That is awesome, thank you. And I will make sure to put my code in blocks. I will try to run it today.

Thank you


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Google [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited