Remove Tabs Chr(9)

December 3, 2009 at 03:30:24
Specs: Windows XP
Hi,

Hopefully someone can help, I have a text file where some of the lines have a tab within them which is forcing the data on to a new row.

Is there a way with way a batch file that I can remove these before importing the file.

Thanks in advance


See More: Remove Tabs Chr(9)

Report •


#1
December 3, 2009 at 04:27:51
@echo off > newfile & setLocal enableDELAYedexpansion

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


=====================================
Helping others achieve escape felicity

M2


Report •

#2
December 3, 2009 at 05:10:42
Thanks for the reply, can I be stupid and ask where Ireference the file I want too edit and what exactly is happening on each line. Thanks

Report •

#3
December 3, 2009 at 05:39:40
Put your file name in the parentheses where I have:

(my.txt)

I wonder if my first post got mashed.

===============================

@echo off > newfile & setLocal enableDELAYedexpansion

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


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
December 3, 2009 at 06:06:17
OK cheers, changed to

@echo off > newfile & setLocal enableDELAYedexpansion

for /f "tokens=*" %%a in (C:\Documents and Settings\john.smith\Desktop\Billed Revenue Intl (Detail Inc Circuit).txt) do (
set S=%%a
set S=!S:	=!
>> newfile echo !S!
)

Batch file runs for a split secound then i end up with an empty file called newfile

What have I done wrong cheers


Report •

#5
December 3, 2009 at 06:14:05
Change directory to where the file is.


=====================================
Helping others achieve escape felicity

M2


Report •

#6
December 4, 2009 at 05:54:38
Hi M2,

Does usebackq exist on win2k?

Don't want to stomp on your post be changing dir won't help
because the filename itself still contains spaces and brackets
which will cause failure.

As far as I see it "usebackq", 8dot3 file name aliases or
renaming the file are the only options.

@echo off > newfile & setLocal enableDELAYedexpansion

for /f "usebackq tokens=*" %%a in ("C:\Documents and Settings\john.smith\Desktop\Billed Revenue Intl (Detail Inc Circuit).txt") do (
set S=%%a
set S=!S:	=!
>> newfile echo !S!
)


Batch Variable how to


Report •

#7
December 5, 2009 at 00:18:09
Hi Judago,

Yes, w2k has bq. And you're right about the verserk file name.


=====================================
Helping others achieve escape felicity

M2


Report •


Ask Question