I want to make last column width fixed by adding space. suppose I have data lik e
1 aaa abcdefgh
2 bb abcd
3 ccc abcde
This should be output into a file like -
1 aaa abcdefgh "
2 bb abcd "
3 ccc abcde "
Here I want to make last column data length as 10 characters. I have put " just to denote white space here.
Please help!
Adding space to line to make it fixed length
Moderator: DosItHelp
Re: Adding space to line to make it fixed length
You need to have your "last column" in a separate variable.
Regards
aGerman
Code: Select all
@echo off &setlocal
set "var1=abc"
set "var2=z"
echo before:
echo "%var1%"
echo "%var2%"
call :fix10 var1
call :fix10 var2
echo after:
echo "%var1%"
echo "%var2%"
pause
exit /b
:fix10
setlocal EnableDelayedExpansion
set "s=!%~1! "
endlocal &set "%~1=%s:~,10%"
exit /b
Regards
aGerman