Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello All,
I've seen all the batch file on removing space and replace by tabs but I was wondering if this is possible to do so. I have a text file that have major delimiters tab but it's always the same files. I want to eliminate specific tabs like..
A B C D E
1 2 3 4 5
result:
A B C
1 2 3
removing all the time..
D E
4 5if that possible, please let me know please..that solve my issue of doing it manually. thanks in advance. This site helps a lots of coders!

These are my standard text parsing questions for batch files: 1. Does the file to be parsed contain any of the characters in this set?: {!%"|^&<=>*;}. 2. If the file is to be split on a delimiter: I. Do all of the fields contain data? Example: Say the data is to be split on a comma, will there be any filds like "field1,,field3" II. Do any of the fields contain the delimiter in any way? Example: Sometimes fields contain data that is double quoted and contains the delimiter. An example on a comma delimited field, "field1","field,2","filed3" ..... 3. Is the data regular in terms of line breaks? A good example of text that may want to be parsed is irregular in terms of line breaks is html/xml, because these types of data can be spread out over one or more lines with little consistency it can be extremely difficult to parse correctly in batch files. Please show an example of exactly what the data currently looks like and how it should look after parsing. and be sure to note what is a white space is a tab or space. Also be aware that the built in text parsing capabilities of batch are extremely limited. Some things are incredibly hard to near impossible while others can be easy to moderate. Regardless of how easy something may seem some circumstances may prove difficult. A good example is find and replace, with some data sets it proves easy, but I am yet to see a batch file that can find and replace any combination of ASCII in a text file that may also contain any combination of ASCII.
You have some of the boxes ticked but the others are equally important.
Another thing I'm not clear on, is it simply that you want to remove "d" and "e" and leave the rest of the data the same or do you also want the tabs between "a", "b" and "c" replaced with spaces?

that's awesome comments.
The file is always the same coming from excel format. Then the user's save it as text file. So the text file itself will be automatically separated by tabs/space. No comma or qoute or any wild characters. The format wont change.
Sample I have are:BEFORE:
FRUIT TYPE Color QTY
APPLE MACINTOSH RED 20
BANANA SWEET YELLOW 30
PINEAPPLE ROUGH GREEN 50AFTER:
FRUIT Color
APPLE RED
BANANA YELLOW
PINEAPPLE GREENAlso I want this on tabs not by comma.
Thanks agaiN!

Based on what you have told me :
for /f "usebackq tokens=1-3 delims " %%a in ("your file") do ( >> "newfile" echo %%a %%b %%c )
If you want the file to have the same name you could use his:move "newfile" "yourfile"

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |