Batch text file double tab replacement

Microsoft Windows xp professional w/serv...
January 11, 2010 at 01:28:57
Specs: Windows XP SP3, core2 duo, 2G
Dear reader!

For the past few days I've been working on a large TSV file. I've created a script that turns the file into multiple .xls files. I've got one problem I can't seem to solve on my own so I'd much appreciate your help on this:

Some lines in TSV file contain no data in random tab separated boxes, so the txt file has a double tab in that place. My FOR /F loop that uses a tab as a delimiter then takes the next string it finds and offsets all the data from that point on (in that line).

What I need to do is add something to my script to replace <tab><tab> with <tab>something<tab>

Can you please help me do this? I've tried using double tab as a delimiter, using a find function and busted my head for many hours over this..

Thank you for your time and effort.


See More: Batch text file double tab replacement

Report •

January 11, 2010 at 02:53:50
Do you want to change all the double tabs to single tabs?

Helping others achieve escape felicity


Report •

January 12, 2010 at 02:50:31

No, If I replace all double tabs the result will be the same as it is now, I need to replace the double tab with <tab>xxx<tab>

Thanks for commenting!

Report •

January 12, 2010 at 22:20:21
:: twotab.bat  Wed 13-01-2010 13:18:42.34
@echo off > newfile & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in (myfile) do (
set S=%%a
set S=!S:		=	xxx	!
>> newfile echo.!S!

Report •

Related Solutions

January 13, 2010 at 08:19:26
You are the man! I've tried something like this but I think I didn't use !! for the replacement.

It works just like I want it! Well I had to change the delims, space is no good for me.Thank you very much!!

Also I used a few loops so I got triple tabs first, since they can sneak into the file too:P

for /f "tokens=* delims=*" %%a in (myfile.temp) do (
set S=%%a
set S=!S: = xxx !
>> newfile.temp echo.!S!


Report •

Ask Question