Click here for important information about

Batch File to delete character in a field

March 29, 2010 at 16:15:39
Specs: Windows 2000
I need a help to create a batch file to edit a field.Specifically delete the suffix "I2" on the last field of every line.

Here is a sample lines of my text csv file.

"03/06/08","8561","8561","NDF STJOHN","ST JOHN AMBULANCE,SERVICE","7.70","393595I2"
"03/06/08","8277","8277","NDF BUNTON","BUNTON,MRS","10.60","393608I2"
"03/06/08","8531","8531","NDF POLICE","POLICE DEPARTMENT,NZ","7.80","393610I2"
"03/06/08","8531","8531","NDF POLICE","POLICE DEPARTMENT,NZ","15.60","393611I2"
"03/06/08","8531","8531","NDF POLICE","POLICE DEPARTMENT,NZ","7.80","393637I2I2"

Last field always with I2 on the end.want it deleted after running the batch file.

Thanks !

See More: Batch File to delete character in a field

March 29, 2010 at 16:52:39
@echo off & setlocal enabledelayedexpansion
for /f "tokens=*" %%a in (test.csv) do (
set xx=%%a
set xx=!xx:~-3!"
>> newfile echo !xx!
::---- end
examine "newfile" to see if this thing worked.
note that exclams in the file might cause problems.
if you need more help, suggest posting to the "programming" forum, lots of able-brained help over there.
ps: after posting, i saw windows 2000 as your op.sys, but since this was posted in winXP, i'll leave my offering, but it might not work on win2000.

Report •
Related Solutions

Ask Question