batch programming-Remove Space

Don't know / DON'T KNOW
May 19, 2009 at 19:33:44
Specs: Windows XP, Dual Core2 1.6GHz / 2GB
I want to do this
%USERNAME%=Elaine Jack --> ElaineJack (without a space in between two words)

i.e. %USERNAME% is a system variable, user name may be just one word like John, peter and so on. I will make this variable name to create a zip and run another code.

Refer to courtesy help from
But it still fails.

Any help is appreciated. ThanksRef Link --Computing.net

@Echo Off

Set MyVar=AA AAAA
Echo MyVar=[%MyVar%]

Call :TRIM %MyVar%

Echo MyVar=[%MyVar%]
Set MyVar=
GoTo :EOF

:TRIM
Set MyVar=%*
GoTo :EOF


See More: batch programming-Remove Space

Report •


#1
May 19, 2009 at 23:59:48
I thought I was with you after reading just your first comment. Then it got hazy.

But to simply get a space out of a string:
===========================================

@echo off & setLocal EnableDelayedExpansion

set str=joe smith
echo !str!

for /f "tokens=1-2 delims= " %%a in ("!str!") do (
set var=%%a%%b
)
echo !var!

-----------------------------


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
May 20, 2009 at 11:06:33
Set MyVar=AA AAAA BB BBBB
set MyVar=%MyVar: =%
echo %MyVar%

Report •

Related Solutions


Ask Question