Is there something in a BATCH file that would double a % character?
The test.txt INPUT file contains the following "
Hello World
The filename is : filename with spaces and 50% percentages signs.txt
The %~nf removes extenstions
Is there something to double a % charactor?
As I would like 50% to be outputed as 50%%
because the output of this batch is to create input for another batch.
"
The batch file.
@echo off
setlocal EnableDelayedExpansion
echo. > test2.txt
for /f "tokens=*" %%a in ('type test.txt') do (
if "%%a"=="Update=Yes" (
@echo Update=No >> test2.txt
) else if "%%a"=="Update=No" (
@echo Update=Yes >> test2.txt
) else if "%%a"=="" (
rem Questions TWO
rem print a blank line doesn't work
@echo. >> test2.txt
) else (
set tmpvar=%%a
set str=!tmpvar:%%=%%%%!
echo !str! >> test2.txt
)
)
start test2.txt
The test2.txt output is (Note No Blank Line under Hello World)
Hello World
The filename is : filename with spaces and 50%% percentages signs.txt
The %%~nf removes extenstions
Is there something to double a %% charactor?
As I would like 50%% to be outputed as 50%%%%
because the output of this batch is to create input for another batch.
Problem Two: How do I check if %%a is an empty line?
This does work but would require 400 lines; is there a way to do it using a For LOOP?
@echo off
set STR2=ON%%E
echo This is STR2 %STR2%
IF "%STR2:~0,1%"=="%%" (set STR3=%STR3%%%%%) else set STR3=%STR3%%STR2:~0,1%
IF "%STR2:~1,1%"=="%%" (set STR3=%STR3%%%%%) else set STR3=%STR3%%STR2:~1,1%
IF "%STR2:~2,1%"=="%%" (set STR3=%STR3%%%%%) else set STR3=%STR3%%STR2:~2,1%
IF "%STR2:~3,1%"=="%%" (set STR3=%STR3%%%%%) else set STR3=%STR3%%STR2:~3,1%
echo This is STR3 %STR3%
pause