Home > Software design >  How to extract between keywords using batch
How to extract between keywords using batch

Time:01-06

If you'll don't mind I need help with an extraction script I have
This script works great and fast as long as my txt file is under 100K lines
The file I tested has 60K lines and is a Json format
and it works great
but when I tested it on a txt file over 500K txt file it took a very long time,
to where I just closed out the the CMD window

I need help to find a better way to improve the script to extract content from a txt file over 500K lines

Here is my Script

@ECHO OFF
SETLOCAL 

SET "sourcedir=%~dp0New folder 1"
SET "destdir=%~dp0New folder 2"

for /f "tokens=1 delims=[]" %%a in ('find /n "name"^<"%sourcedir%\nsb.txt" ') do set /a start=%%a
for /f "tokens=1 delims=[]" %%a in ('find /n "caow"^<"%sourcedir%\nsb.txt" ') do set /a end=%%a
(
for /f "tokens=1* delims=[]" %%a in ('find /n /v ""^<"%sourcedir%\nsb.txt" ') do (
 IF %%a geq %start% IF %%a leq %end% ECHO(%%b
 )
)>"           
  • Related