batch to remove character from a string

September 16, 2010 at 22:26:28
Specs: Windows 7
this may seem basic but Is there a way to create a batch to remove char from a string from a txt file. ?

If I already have this inside the .txt file

2005060.png
2005070.png
2005080.png
2005090.png

so is there a way to create a batch file that will remove the .png at the end to show only this in a new .txt file

2005060
2005070
2005080
2005090

I learned how to add a string at the end but not vice-versa

Thanks for any help on this! :)


See More: batch to remove character from a string

Report •

#1
September 16, 2010 at 23:52:22
@echo off > newfile & setLocal enableDELAYedeXpansion

for /f "tokens=* delims= " %%a in (myfile) do (
set S=%%a
set S=!S:~0,-4!
>> newfile echo.!S!
)


=====================================
Helping others achieve escape felicity

M2


Report •
Related Solutions


Ask Question