notepad++ - Batch loop through file -


i'm trying make batch process in notepad++ count number of duplicate lines text selected.

so far have notepad++ working fine

npe_console v+ cls echo $(current_word) con_saveto "h:\tmp.txt" npe_console v- 

this scripts saves selected text tmp.txt issue being includes, @ bottom, con_saveto "h:\tmp.txt" can live now.

edit: also, not think notepad++ issue here since try running batch file cmd line , same errors/problems. tried setting tmp.txt file manually , still same issues.

my batch file causing issues:

::@echo off cd "h:\" set counter=0 set prev=a  /f "tokens=*" %%l in (tmp.txt) (     set blnout=0     set curline="%%l"      if /i %prev%==%curline% (         set counter=%counter%+1         set blnout=1     )     if %blnout%==0 (         if %prev%==a (             set counter=%counter%+1             set blnout=1         )         if %blnout%==0 (             echo %curline%- %counter%             set counter=1         )     )     set prev=%curline% ) 

i've tried can think of, including splitting off process function, keep getting errors unexpected ) or, if run, not loop through file.

currently, tmp.txt:

1 2 3 4 5 6 7 8 1 4 5 8 4 3 4 4 5 

so ideal output is:

1 - 2 2 - 1 3 - 2 4 - 5 5 - 3 6 - 1 7 - 1 8 - 2 

@echo off setlocal enabledelayedexpansion %%i in (prev) set "%%i=" /f "delims=" %%i in ('sort ^<temp.txt') (  if defined prev (   if "!prev!"=="%%i" (set /a count+=1) else (   echo !prev! - !count!   set "prev="   )  )  if not defined prev (   set prev=%%i   set /a count=1  ) ) echo %prev% - %count% 

here's version. sort input file group lines together, when line-contents change, display previous contents , count , reset counter , record of previous line.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -