Reduce spaces in between 2 words in txt file

Hi,

I have a txt file which has data like this

Sharath     Sharath.reddy@plc.com

I want the data like this
Sharath Sharath.reddy@plc.com

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
 
oBdAConnect With a Mentor Commented:
Try this; just adjust the names of the file to read and the file with the removed spaces:

@echo off
setlocal enabledelayedexpansion
set InputFile=test.txt
set OutputFile=SpacesRemoved.txt
if exist "%OutputFile%" del "%OutputFile%"
for /f "tokens=*" %%a in ('type "%InputFile%"') do (
  set Line=
  for %%l in (%%a) do set Line=!Line! %%l
  >>"%OutputFile%" echo !Line:~1!
)
0
 
Brian PiercePhotographerCommented:
Load it into word  and use filnd/replace to find two spaces and replace with one space - you may need to do the find/replace all several times to get rid of all the double spaces
0
 
LuckyLuke57Commented:
Or more complete:

Do a first find and replace
- search for the tab-character
- replace with one space

Then as KCTS suggested do as much as you need
- search for two spaces
- replace with one spac

Luke
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
bsharathAuthor Commented:
But there are a differerent of space
One have 1 space 2,3,4,5,6,7,8,9, so on....
0
 
LuckyLuke57Commented:
If you start with 1,2,3,4,5,6,7,8,9 spaces
If you do the find and replace the first time, you will have
1, 2,3,4,5,6,7,8 as a result,
One more time find and replace and you have
1, 2,3,4,5,6,7
and do this as much as is necessary
0
 
LuckyLuke57Commented:
If you have a lot of spaces, you can start with a find and replace from 5 spaces to one which you do a few times, after that you have to do the 2 to 1 only max 4 times.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.