Page 1 of 1
How to convert easily every TAB character to a Space.
Posted: 02 Jul 2013 06:23
by alan_b
I am using a utility that produces an output report upon a vast number of files.
Every file is reported with its complete path and name on a separate line, e.g.
The TAB character between the path and the name is causing me grief,
and I wish to remove each TAB, or replace with a normal Space.
Is there a simple command available in DOS to do this,
or do I have to dust of my tenuous grasp of writing a script and read each each line and replace with something like
http://www.dostips.com/?t=Snippets.ReplaceRegards
Alan
Re: How to convert easily every TAB character to a Space.
Posted: 02 Jul 2013 07:01
by foxidrive
The MORE command has a switch to convert TABs to a number of spaces.
Re: How to convert easily every TAB character to a Space.
Posted: 02 Jul 2013 07:05
by Squashman
Those are tabs in the code.
Code: Select all
@echo off
SET VAR1=W:\#1\ bookmarks-2012-03-10.json
echo %VAR1%
SET VAR1=%VAR1: =%
echo %VAR1%
pause
output
Code: Select all
W:\#1\ bookmarks-2012-03-10.json
W:\#1\bookmarks-2012-03-10.json
Press any key to continue . . .
You could also do this with a FOR LOOP if it is just one tab.
Re: How to convert easily every TAB character to a Space.
Posted: 02 Jul 2013 07:53
by dbenham
I think foxidrive is on track for the most convenient answer, although MORE always converts tab into 1 or more spaces. The switch only controls the tab stops. Set the tab stop to 1 to convert every tab into exactly 1 space.
Code: Select all
more /t1 yourfile.log >yourfile.log.new
move /y yourfile.log.new yourfile.log >nul
Or better yet, pipe your command output directly to MORE
Code: Select all
yourCommand | more /t1 >yourfile.log
Dave Benham
Re: How to convert easily every TAB character to a Space.
Posted: 02 Jul 2013 07:56
by foxidrive
/t0 removes the tabs
Code: Select all
/Tn Expand tabs to n spaces (default 8)
Re: How to convert easily every TAB character to a Space.
Posted: 02 Jul 2013 08:07
by dbenham
foxidrive wrote:/t0 removes the tabs
Code: Select all
/Tn Expand tabs to n spaces (default 8)

Thanks, I did not know that

So my statement should be amended to "MORE always converts a tab into 0 or more spaces". It is a shame that there is no option to preserve tabs
Dave Benham
Re: How to convert easily every TAB character to a Space.
Posted: 02 Jul 2013 11:06
by alan_b
Many thanks,
MORE is a perfect solution for me
Regards
Alan