Page 1 of 1

Can Everything search text inside text files?

Posted: Sun Jun 17, 2018 5:00 pm
by Vortex
Can Everything search text inside text files?

I have a text file with 3,200 lines, each containing an authors name and associated book title. Example:

Code: Select all

George Orwell 1984
H. G. Wells War of the Worlds
Isaac Asimov I, Robot
I also have a folder containing a dozen text lists of ebook filenames (Some of the lists have over 500K lines.), for example:

Code: Select all

George Orwell - 1984 (epub).rar
H G Wells - War of the Worlds (pdf).rar
Isaac Asimov - [Robot 0.1] - I, Robot (Mobi).rar 
I need to search the text files of filenames for the 3,200 author and titles, and output the results to a 3rd text list.

The filenames also contain other stuff like series info, format, etc, so I'm looking for any lines that contain those authors names and titles.

Can anyone please help me out with the code. Thanks.
EDIT: Added more examples.

Re: Can Everything search text inside text files?

Posted: Sun Jun 17, 2018 6:27 pm
by Stamimail
viewtopic.php?t=5546
viewtopic.php?t=6376

btw, try to add more lines in your example, to make it more clear.

Re: Can Everything search text inside text files?

Posted: Thu Jun 21, 2018 2:04 am
by void
Please try the content: search function, for example:

d:\ebooks\ *.txt content:"George Orwell 1984"
d:\ebooks\ *.txt content:"H. G. Wells War of the Worlds"
d:\ebooks\ *.txt content:"Isaac Asimov I, Robot"

Re: Can Everything search text inside text files?

Posted: Thu Jun 21, 2018 8:07 pm
by NotNull
The content: function is not of much use in this case, as it will just report the (one of the dozen) filenames wherein this text was found (like index1.txt), not the actual filename (like George Orwell - 1984 (epub).rar).


Do you have those files (like George Orwell - 1984 (epub).rar) on your disk? then you can skip searching in the dozen index files.

The question itself is rather vague. What should be in the output file? What is this "code" you are referring to?
Please explain yourself further ..

Note that you probably will have some mismatches. That becomes apparent even in your own examples: H G Wells vs H.G. Wells (where HG Wells is yet another possibility(

Re: Can Everything search text inside text files?

Posted: Wed Jun 27, 2018 12:43 pm
by NotNull
Regarding the "code": Do you mean some sort of script? I think that can be done quite easily (depending on what should be in the output file).

Re: Can Everything search text inside text files?

Posted: Tue Aug 28, 2018 9:04 pm
by NotNull
I was cleaning out my harddisks and found a script lying around to do what (I think) you are looking for. Completely forgot about that one ..

Instructions:
- Save FindBook.cmd in an empty folder
- Save your "text file with 3,200 lines" as titlelist.txt in that folder
- Create a folder "filelist" in that folder.
- Copy the "dozen text lists of ebook filenames" to the filelist folder

Result should be something like:

Code: Select all

C:\test\boek\FindBook.cmd
C:\test\boek\titlelist.txt

C:\test\boek\filelist\index1.txt
C:\test\boek\filelist\index2.txt
- Run FindBook.cmd

Output:

Code: Select all

filelist\index1.txt:George Orwell - 1984 (epub).rar
filelist\index2.txt:George Orwell - 1984 (epub).rar
filelist\index1.txt:H G Wells - War of the Worlds (pdf).rar
filelist\index2.txt:Isaac Asimov - [Robot 0.1] - I, Robot (Mobi).rar

Press any key to continue . . .


This was tested with the following inputfiles:

Titlelist.txt:
George Orwell 1984
H. G. Wells War of the Worlds
Isaac Asimov I, Robot

Index1.txt
George Orwell - 1984 (epub).rar
H G Wells - War of the Worlds (pdf).rar
Some random filename.txt

Index2.txt
George Orwell - 1984 (epub).rar
Isaac Asimov - [Robot 0.1] - I, Robot (Mobi).rar
Some random filename.txt



Findbook.cmd

Code: Select all

@echo off
pushd "%~dp0"

for /f "delims=" %%x in (titlelist.txt) DO call :AXI "%%x"
echo.
pause
goto :EOF


:AXI
	set ff=%~1
	set regex=^%ff: =.*%.*
	findstr /i /R "^%regex%" filelist\*

goto :EOF