Batch File OR VBS

December 2, 2009 at 05:19:59
Specs: Windows XP
I have a text file containing numeric and non-numeric characters. I want to create a batch or vbs to remove these non-numeric characters. Text file is stored C:\TEST1.TXT

See More: Batch File OR VBS

Report •

December 2, 2009 at 11:38:51
this is assuming the numbers are digits only (no decimal points etc.) if you have a file test2.txt, be sure to protect it as it gets deleted and overwritten by this code!

@echo off && setlocal enabledelayedexpansion
del test2.txt 2>nul
for /f "tokens=* delims=" %%a in (test1.txt) do (
set cc=%%a
for /L %%b in (0,1,9) do (
if "!cc!" neq "" set cc=!cc:%%b=!)
echo !cc! >> test2.txt)
:enable foll. line (remove colon) for active replacement
:move /y test2.txt test1.txt

Report •
Related Solutions

Ask Question