Find string in a big txt file and rturn the number line where the string is
Moderator: DosItHelp
Find string in a big txt file and rturn the number line where the string is
i'm working with vb6.
possible to:
Find a string in a big txt file and return the number of line where the string is found?
Naturally store the line number in a variable
note:
i need to integrate the batch in my vb6 application
tks and sorry for my bad english.
possible to:
Find a string in a big txt file and return the number of line where the string is found?
Naturally store the line number in a variable
note:
i need to integrate the batch in my vb6 application
tks and sorry for my bad english.
Re: Find string in a big txt file and rturn the number line where the string is
Code: Select all
for /f "delims=:" %%i in ('findstr /nc:"your string" "your file.txt"') do set "n=%%i"
Any good reason why you don't do this task in VB directly?i need to integrate the batch in my vb6 application
Steffen
Re: Find string in a big txt file and rturn the number line where the string is
tks!
Sorry for delay.
but i need to use vb6.
possible to use the VB6 Shell?
If yes, have an idea for vb6 code?
Tks
Sorry for delay.
but i need to use vb6.
possible to use the VB6 Shell?
If yes, have an idea for vb6 code?
Tks
Re: Find string in a big txt file and rturn the number line where the string is
tks!aGerman wrote: ↑03 May 2019 03:47... untested though.Code: Select all
for /f "delims=:" %%i in ('findstr /nc:"your string" "your file.txt"') do set "n=%%i"
Any good reason why you don't do this task in VB directly?i need to integrate the batch in my vb6 application
Steffen
Sorry for delay.
but i need to use vb6.
possible to use the VB6 Shell?
If yes, have an idea for vb6 code?
Tks
Re: Find string in a big txt file and rturn the number line where the string is
I'm not experienced with VB6. This is a Batch forum and I offered a Batch solution...but i need to use vb6.
Steffen
Re: Find string in a big txt file and rturn the number line where the string is
ok
i can trap your code in a file .bat?
In this case i know the code in vb6 to lunch the bat.
if is possible, can you integrate your code to return the number of line finded in c:\test\myresult.txt
tks
Re: Find string in a big txt file and rturn the number line where the string is
Just a guess ...
No idea if that is what "return the number" means in your case.
Steffen
Code: Select all
@for /f "delims=:" %%i in ('findstr /nc:"your string" "your file.txt"') do exit /b %%i
Steffen
Re: Find string in a big txt file and rturn the number line where the string is
HI Steffen, TKS FOR CODE.!aGerman wrote: ↑06 May 2019 11:07Just a guess ...No idea if that is what "return the number" means in your case.Code: Select all
@for /f "delims=:" %%i in ('findstr /nc:"your string" "your file.txt"') do exit /b %%i
Steffen
To save the result of bat in c:\testdir\result.txt, in this case the number of line found?
is this correct:
@for /f "delims=:" %%i in ('findstr /nc:"your string" "your file.txt"') do exit /b %%i > c:\testdir\result.txt
Re: Find string in a big txt file and rturn the number line where the string is
No, you have to redirect the ECHO output to the file.
Steffen
Code: Select all
@for /f "delims=:" %%i in ('findstr /nc:"your string" "your file.txt"') do >"c:\testdir\result.txt" echo %%i
Re: Find string in a big txt file and rturn the number line where the string is
Is this correct?aGerman wrote: ↑07 May 2019 06:16No, you have to redirect the ECHO output to the file.SteffenCode: Select all
@for /f "delims=:" %%i in ('findstr /nc:"your string" "your file.txt"') do >"c:\testdir\result.txt" echo %%i
Last edited by sal21 on 07 May 2019 06:48, edited 1 time in total.
Re: Find string in a big txt file and rturn the number line where the string is
Does it work?
How should I know the content of your 985.txt and if all paths are correct and existing?
Steffen
How should I know the content of your 985.txt and if all paths are correct and existing?
Steffen
Re: Find string in a big txt file and rturn the number line where the string is
OPS.....
in txt file i can have:
AAAA
AAAA
AAAA
The bat capture all AAAA...
in my work i need to capture only the first occurrence of AAAA, and exit from the code, possible?
Re: Find string in a big txt file and rturn the number line where the string is
Try it this way
Steffen
Code: Select all
@for /f "delims=:" %%i in ('findstr /nc:"your string" "your file.txt"') do >"c:\testdir\result.txt" echo %%i&exit /b