Delete lines from file using Batch Program

Microsoft Windows xp professional sp2c e...
April 21, 2010 at 21:46:13
Specs: Windows XP
Hi All,

I have a file with 3 columns (Bank Name,
Account Number and Amount). My
requirement, I need to delete lines using
windows batch script:

1. Which are having Alphanumeric characters
in Account Number (eg. Line3).
2. Which are having 0.00 in amount. (eg.
3. And also I need to delete the text "End Of

Sample Data:-
End of File

Phani Akella

See More: Delete lines from file using Batch Program

Report •

April 22, 2010 at 07:58:56
The following batch should do the trick, I tested it and the script worked fine, but be aware it is a "borderline" batch so pay attention to the result (in output.txt).

At prompt type BatchName PathName/FolderName without double quotes.

@echo off & setlocal EnableDelayedExpansion
if not defined _A (set _A=ON & %0 %* 2> nul)
type nul > output.txt
for /F "tokens=1-3 delims=," %%a in ('type "%*" ^| find /V ",0.00" ^| find /V /I "End of File"') do (
  set /A _A=%%b
  if "!_A!"=="%%b" echo.%%a,%%b,%%c>> output.txt
:: End_Of_Batch

Report •
Related Solutions

Ask Question