Trim Left

Trim spaces from the beginning of a string via "FOR" command.

Description: Use the FOR command to trim spaces at the beginning of a variable. In this example the variable to be trimmed is str.
Script:
1.
2.
3.
4.
set str=               15 Leading spaces to truncate
echo."%str%"
for /f "tokens=* delims= " %%a in ("%str%") do set str=%%a
echo."%str%"
Script Output:
 DOS Script Output
"               15 Leading spaces to truncate"
"15 Leading spaces to truncate"