The syntax "LEFT" you are requesting is to use the variable substring extension: %var:~,14%
The following code will execute "LEFT 14" on each line containing the line "Version"
setlocal enabledelayedexpansion del output.ini for /f "tokens=*" %%a in (input.ini) do ( set var=%%a if not {!var!}=={!var:Version=!} set var=!var:~,14! echo.!var! >> output.ini ) endlocal
If there are other lines with the word "Version", you can also change the loop to use the counter.
setlocal enabledelayedexpansion del output.ini set counter=0 for /f "tokens=*" %%a in (input.ini) do ( set var=%%a set /a counter=!counter!+1 if !counter! EQU 2 set var=!var:~,14! echo.!var! >> output.ini ) endlocal
Please note that in both cases, you may need more work if your file contains special characters, such as |, <, or>
source share