Find in files - lines of a text file

English support forum

Moderators: Stefan2, white, sheep, Hacker

Post Reply
BlueWings
Junior Member
Junior Member
Posts: 3
Joined: 2019-06-11, 11:49 UTC

Find in files - lines of a text file

Post by *BlueWings » 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

User avatar
Horst.Epp
Power Member
Power Member
Posts: 3375
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Find in files - lines of a text file

Post by *Horst.Epp » 2019-06-11, 13:39 UTC

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 10 Home x64 May 2019 Update, Version 1903 (OS Build 18362.295)
Intel(R) Core(TM) i7-4770 CPU @ 3.40GH, 16GB RAM
TC 9.22a x64 and x86, Everything 1.4.1.947 (x64)

User avatar
Dalai
Power Member
Power Member
Posts: 6626
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Find in files - lines of a text file

Post by *Dalai » 2019-06-11, 13:57 UTC

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
Athlon X4 880K, 16 GiB RAM, Gigabyte F2A88X-D3HP, Win7 x64

Plugins: Services2, Startups

BlueWings
Junior Member
Junior Member
Posts: 3
Joined: 2019-06-11, 11:49 UTC

Re: Find in files - lines of a text file

Post by *BlueWings » 2019-06-11, 14:12 UTC

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

User avatar
Hacker
Moderator
Moderator
Posts: 11246
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: Find in files - lines of a text file

Post by *Hacker » 2019-06-15, 10:52 UTC

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.

BlueWings
Junior Member
Junior Member
Posts: 3
Joined: 2019-06-11, 11:49 UTC

Re: Find in files - lines of a text file

Post by *BlueWings » 2019-07-03, 11:13 UTC

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

User avatar
tbeu
Power Member
Power Member
Posts: 1253
Joined: 2003-07-04, 07:52 UTC
Location: Germany
Contact:

Re: Find in files - lines of a text file

Post by *tbeu » 2019-07-08, 11:19 UTC

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 Preview, Autodesk Revit Preview, FileInDir, ImageMetaData (JPG Comment/EXIF/IPTC/XMP), MATLAB MAT-file Viewer, SolidWorks Preview and more

Post Reply