Note: The file Default.txt contains one line with these three characters:1:X
@echo off
set r=0
:: For loop retrieves lines of text f
Prudviraj's answer answers why your original code doesn't work, but for an easier way of padding a string to 39 characters, you could try:
Make39.bat
@echo off
setlocal
set "R=%1"
set "R=%R% " REM append 39 spaces
set "R=%R:~,39%" REM take first 39 characters
echo :123456789012345678901234567890123456789:
echo :%R%:
which works as follows:
S:\>make39 abc
:123456789012345678901234567890123456789:
:abc :
S:\>make39 "Quite a long string"
:123456789012345678901234567890123456789:
:Quite a long string :
Your comments seem to imply no string will initially be longer than 39 characters; you would have to get more inventive if this were possible (I would probably take the first 39 characters of the original R and see if that and R differ: if they did, the original would have been longer, so there would be no need to add padding).