1.

Solve : Help with set command variable subsitution?

Answer»

Hi guys am a little stuck with my little batch script basically i need to replace all the spaces with %20's of a filename string ( %~n1 )
Code: [Select]ECHO on

set SENTFILE=%~nx1
set SENTFILE=%SENTFILE: =%20%

echo %SENTFILE%

pause
I've tried all sorts to make this work it just seems that I can't escape the % character anyway!
I've tried ^ %% ^^ PUTTING it in brackets quotes etc.. nothing...

Can anybody help ? I know i can do this with vbs script but i'd rather not...

AbyssUK Code: [Select]echo on

set SENTFILE=%~nx1
setlocal enabledelayedexpansion
set SENTFILE=!SENTFILE: =%%20!

echo %SENTFILE%
endlocal

pauseThanks Prince! WORKS like a CHARM!



Discussion

No Comment Found