Find in files - lines of a text file

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
BlueWings
Junior Member
Junior Member
Posts: 4
Joined: 2019-06-11, 11:49 UTC

Find in files - lines of a text file

Post by *BlueWings »

Hello TCMD Fans,

I have a text file with several lines of text separated by CR/LF pairs.
I need to find those files in a dir that contains ANY line of the text file.
TCMD search dialog's "Find text" box is not suitable, because that allows only a single line of text to search for.

Can anyone please suggest me a plugin (or some special trick) that allows this search to execute ?

Thanks a lot in advance,

Peter
#212615 Single user licence
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Find in files - lines of a text file

Post by *Horst.Epp »

BlueWings wrote: 2019-06-11, 13:28 UTC Hello TCMD Fans,

I have a text file with several lines of text separated by CR/LF pairs.
I need to find those files in a dir that contains ANY line of the text file.
TCMD search dialog's "Find text" box is not suitable, because that allows only a single line of text to search for.

Can anyone please suggest me a plugin (or some special trick) that allows this search to execute ?

Thanks a lot in advance,

Peter
From the help:
Find text If this option is checked, you can enter text to be searched.
With \t you find tabstops, and with \n line breaks (ENTER) in texts.
To find a backslash \, you need to give it twice: \\ .

Did you try it with your search criteria ?
Windows 11 Home x64 Version 23H2 (OS Build 22631.3374)
TC 11.03 x64 / x86
Everything 1.5.0.1371a (x64), Everything Toolbar 1.3.2, Listary Pro 6.3.0.69
QAP 11.6.3.2 x64
User avatar
Dalai
Power Member
Power Member
Posts: 9364
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Find in files - lines of a text file

Post by *Dalai »

2Horst.Epp
TC would search exactly for this string, i.e. the lines in this exact order. That's probably not what he wants.

Unfortunately I don't have a good idea right now.

Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
User avatar
BlueWings
Junior Member
Junior Member
Posts: 4
Joined: 2019-06-11, 11:49 UTC

Re: Find in files - lines of a text file

Post by *BlueWings »

Hello Horst, :D
Horst.Epp wrote: 2019-06-11, 13:39 UTC With \t you find tabstops, and with \n line breaks (ENTER) in texts.
That's not good unfortunately, because my goal is to find files that contain only one singe line of a multiple lines text file.
I want to find those files in a dir that contains at least 1 line of a text file (but can probably contain more).
For a small amount of lines that's easy to copy-paste each line into the search dialog's edit box, but I have some files with several hundred lines, and I have about 15 computers to do this task upon.

Thanks a lot,

Peter :o
#212615 Single user licence
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Find in files - lines of a text file

Post by *Hacker »

BlueWings,

Code: Select all

(line 1)|(line 2)|(line 3)
[x] RegEx(2)
:?:

HTH
Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
BlueWings
Junior Member
Junior Member
Posts: 4
Joined: 2019-06-11, 11:49 UTC

Re: Find in files - lines of a text file

Post by *BlueWings »

Finally I decided to choose a little bit different approach, and was able to reduce the possible search patterns downto exectly 2.
Then I got the relevant files with this script :
(which would also be possible with 2 searches in TC)

Code: Select all

find /c "searchpattern1" dir01\*.txt > list1.lst
find /c "searchpattern2" dir01\*.txt >> list1.lst

type list1.lst | findstr /C:": 1" > list2.lst
call BatchSubstitute "---------- DIR01" "DIR01" list2.lst > list3.lst
call BatchSubstitute ": 1" "" list3.lst > list4.lst
for /F "delims=" %%i in (list4.lst) do copy /Y "%%i" "dir02\" 

del list?.lst
https://www.dostips.com/?t=batch.findandreplace

Cheers & t(h)anks :

Peter :D
#212615 Single user licence
User avatar
tbeu
Power Member
Power Member
Posts: 1336
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Re: Find in files - lines of a text file

Post by *tbeu »

Why aren't you using the existing content plugins Textsearch or Filecontent for your task? Have a look at Image: https://tbeu.de/forum/filecontent.png for an example.
TC plugins: Autodesk 3ds Max / Inventor / Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, Mover, SetFolderDate, Solid Edge Preview, Zip2Zero and more
Post Reply