Solved I need a batch file to delete characters from all the lines

December 17, 2012 at 03:18:34
Specs: Windows 7

Iam not a regular programmer,

I want a batch file to delete some part of the text on all the lines from a text file.

the sample text is like this.

"Dec 14,2012 00:00:00.123456789"

I want "Dec 14,2012 00:00:00.XXXXXXXXX" the "X" (123456789) deleted from the text in all the lines.

the number lines may vary as per the duration of the log file (ie may be 500 lines and above)

please help..
thanx in advance ....



See More: I need a batch file to delete characters from all the lines

Report •


#1
December 17, 2012 at 08:18:29

@echo off & setlocal EnableDelayedExpansion
for /F "tokens=1,* delims=." %%j in ('type "MyFile.txt"') do (
  set row=%%k
  set row=!row:~9!
  echo.!row!
) >> "My.File.new"
del "MyFile.txt"
ren "MyFile.new" "MyFile.txt"


Report •

#2
December 18, 2012 at 00:35:46

Thanx for the reply..

but the whole line between the quotes are getting deleted ..

I want only the "123456789" deleted with the remaining text there in the file..

pl help..


Report •

#3
December 18, 2012 at 01:56:37
✔ Best Answer

@echo off & setlocal EnableDelayedExpansion
for /F "tokens=1,* delims=." %%j in ('type "MyFile.txt"') do (
  set row=%%k
  set row=!row:~9!
  echo.%%j !row!
) >> "My.File.new"
del "MyFile.txt"
ren "MyFile.new" "MyFile.txt" 


Report •

Related Solutions

#4
December 18, 2012 at 03:17:38

Sir,

You are really great you have helped me so much. I need to thank you very much..

that was the fitting reply of yours..


Report •


Ask Question