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
Splitting a .txt file into a new .txt file newbie question
Moderator: DosItHelp
Re: Splitting a .txt file into a new .txt file newbie question
You cannot be using
You must mean
Assuming every D line has another character after it, then you could use something like the following:
If you have some D lines that don't have a 6th character, then
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
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
Re: Splitting a .txt file into a new .txt file newbie question
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
Thank you