You can do it as per the following command script:
@setlocal enableextensions enabledelayedexpansion
@echo off
set variable=2005060.png
echo !variable!
if "x!variable:~-4!"=="x.png" (
set variable=!variable:~0,-4!
)
echo !variable!
endlocal
This outputs:
2005060.png
2005060
The magic line, of course, is:
set variable=!variable:~0,-4!
which removes the last four characters.
If you have a file testprog.in
with lines it it, like:
2005060.png
1 2 3 4 5 leave this line alone.
2005070.png
2005080.png
2005090.png
you can use a slight modification:
@setlocal enableextensions enabledelayedexpansion
@echo off
for /f "delims=" %%a in (testprog.in) do (
set variable=%%a
if "x!variable:~-4!"=="x.png" (
set variable=!variable:~0,-4!
)
echo.!variable!
)
endlocal
which outputs:
2005060
1 2 3 4 5 leave this line alone.
2005070
2005080
2005090
Just keep in mind that it won't output empty lines (though it will do lines with spaces on them).
That may not be a problem depending on what's allowed in your input file. If it is a problem, my advice is to get your hands on either CygWin or GnuWin32 (or Powershell if you have it on your platform) and use some real scripting languages.