Solved Remove characters after a specific word

June 5, 2014 at 06:06:15
Specs: Windows 7
Hi everybody.
I have some text lines that I want to modify after a specifc word.
For example this:

2014 05 20140521-140550 BRYAN SPICER EXAM 21052014135036 UNIT N 7A93D19D189CD730C7CF4FD6FBF03980-1

2014 05 20140521-142108 MARY WHITE EXAM 21052014141618 UNIT N 4ED7302B39C9187180002BD3769BC88A-1

In this case, I want to remove the "EXAM" word and everything after it. Here is how I want:

2014 05 20140521-140550 BRYAN SPICER
2014 05 20140521-142108 MARY WHITE

Is there a way to do this using notepad++ or olther similar software.
Thanks in advance


See More: Remove characters after a specific word

Report •

#1
June 5, 2014 at 07:24:53
::====== script starts here ===============
:: remove EXAM and rest of the line
:: afterwrd.bat 2014-06-05 21:03:09.30
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=* delims= " %%a in (myfile) do (
call :sub1 %%a
echo.!S!
) >> NEWFILE
goto :eof

:sub1
set S=
for %%i in (%*) do (
:loop
if "%1" equ "EXAM" goto :done1
set S=!S! %1
SHIFT
goto :loop
)
:done1
goto :eof
::====== script ends here =================

=====================
M2 Golden-Triangle


Report •

#2
June 9, 2014 at 13:33:25
✔ Best Answer
It worked fine. Thanks.

Report •
Related Solutions


Ask Question