Search folders that contain txt files that contains a specific word

English support forum

Moderators: Hacker, petermad, Stefan2, white

rockberto
Junior Member
Junior Member
Posts: 7
Joined: 2024-07-16, 08:42 UTC

Search folders that contain txt files that contains a specific word

Post by *rockberto »

Hi to everyone, sorry for my bad english.
Is there a way in total commander to search and display only folders that contain text files that contain a specific word? For example, I want to see the list of folders that have a .txt file inside that contains the word 2023
I saw that I can find all the text files that contain the specific word, but I would like to have the list of folders and not of the files found
thanks in advance
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 50390
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Search folders that contain txt files that contains a specific word

Post by *ghisler(Author) »

Unfortunately such a function would be terribly slow. It could be done with a plugin, but the user experience would be bad.
Author of Total Commander
https://www.ghisler.com
User avatar
jonathanpoulin
Member
Member
Posts: 131
Joined: 2020-12-19, 12:09 UTC
Location: Saint-Marc-des-Carrières, QC Canada
Contact:

Re: Search folders that contain txt files that contains a specific word

Post by *jonathanpoulin »

ghisler(Author) wrote: 2024-07-18, 13:41 UTC Unfortunately such a function would be terribly slow. It could be done with a plugin, but the user experience would be bad.
Mr. Ghisler, I have a similar use case. Which plugin(s) do you recommend for to achieve that?
Thanks,
Jonathan Poulin
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Search folders that contain txt files that contains a specific word

Post by *Stefan2 »

jonathanpoulin wrote: 2024-07-18, 17:55 UTC Which plugin(s) do you recommend for to achieve that?

one yet to write






 
JOUBE
Power Member
Power Member
Posts: 1664
Joined: 2004-07-08, 08:58 UTC

Re: Search folders that contain txt files that contains a specific word

Post by *JOUBE »

I don't think that anything new is needed: You can just use the normal search for filemask und text and then all the files found copy into a list and pass it to an editor which uses regex to delete the file names and then removes all duplicate directory names. That should be quick and the list would be ready for further use.

However, I make it even easier and faster: After searching and "Feed to listbox", I press Ctrl+Right Arrow (or Ctrl+Left Arrow) on the relevant files and I am in one of the desired directories. You can repeat this as often as you like and even work with tabs... I mmyself uses this very very often...

Jou"For me no need of a Plugin and even not slow"be
User avatar
jonathanpoulin
Member
Member
Posts: 131
Joined: 2020-12-19, 12:09 UTC
Location: Saint-Marc-des-Carrières, QC Canada
Contact:

Re: Search folders that contain txt files that contains a specific word

Post by *jonathanpoulin »

JOUBE wrote: 2024-07-18, 18:32 UTC I don't think that anything new is needed: You can just use the normal search for filemask und text and then all the files found copy into a list and pass it to an editor which uses regex to delete the file names and then removes all duplicate directory names. That should be quick and the list would be ready for further use.

However, I make it even easier and faster: After searching and "Feed to listbox", I press Ctrl+Right Arrow (or Ctrl+Left Arrow) on the relevant files and I am in one of the desired directories. You can repeat this as often as you like and even work with tabs... I mmyself uses this very very often...

Jou"For me no need of a Plugin and even not slow"be
Yes, I was thinking the same. We can do a lot of things with something like Notepad++. And, this is relatively easy to do, not a lot of steps. But, maybe not as effective compared to having a plugin that do it for us, IMHO. This would be more "TC-oriented".
Thanks,
Jonathan Poulin
Fla$her
Power Member
Power Member
Posts: 2985
Joined: 2020-01-18, 04:03 UTC

Re: Search folders that contain txt files that contains a specific word

Post by *Fla$her »

2jonathanpoulin
What do you want to do with these folders after finding them? Maybe it makes sense to write a script?
Overquoting is evil! 👎
User avatar
tuska
Power Member
Power Member
Posts: 4046
Joined: 2007-05-21, 12:17 UTC

Re: Search folders that contain txt files that contains a specific word

Post by *tuska »

2rockberto

Hi,
try this in tool 'Everything' version 1.5.0.1383a (x64) - (please see my signature):
  1. Everything Options - 1.5.0.1383a (x64) > Content > ✅ Index file content > Include only folders: ... >
    Include only files: *.txt (note the tooltip...)
  2. Right-click on the column headings > Add Columns > Windows Property System > Folder name (System.ItemFolderNameDisplay) > OK
    [The name of the column was translated by me and could also be different. The important thing is: System.ItemFolderNameDisplay].
  3. Search for: *.txt content:"word 2023"
  4. Click in the search result and press Ctrl + A
  5. Menu "File" > Copy Property > Folder name
  6. In the search box, overwrite the search query with: filelist1: <-- Attention: Do NOT paste this text via the clipboard! file-list:1
  7. Hold down the Ctrl key and click IN THE TEXT "filelist1:" in the search box -> the "Edit File List 1" window appears [empty].
  8. Press Ctrl+V to insert the folder names. Do NOT press the "OK" button now!
  9. Click on the "Export..."-button
  10. Save the file, e.g. with the name: "Folder_column-'Folder name'.efu" - File type: EFU 'Everything' File List (*.efu)
  11. Click on the "Cancel" button in the "Edit File List 1" window.
  12. Open the file "Folder_column-'Folder name'.efu" with a text editor, e.g. using the F4 key in Total Commander
    (Configuration > Options... > Edit/View > Editor for F4).
The desired folder names are listed in the .EFU file.


Windows 11 Pro (x64) Version 23H2 (OS Build 22631.3880)
TC 11.03 x64/x86 | 'Everything' 1.5.0.1383a (x64)
Search queries: Total Commander <=> 'Everything' <= Windows Search
Troubleshooting | Troubleshooting Information 1.5
rockberto
Junior Member
Junior Member
Posts: 7
Joined: 2024-07-16, 08:42 UTC

Re: Search folders that contain txt files that contains a specific word

Post by *rockberto »

thanks everyone for the replies.
I solved it this way: I first searched for all the .txt files that contained the keyword. I renamed the extension of these files. Then I searched for only the folders that contained the files with the new extension and moved the folders. Then I put the right extension back on the .txt files
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6954
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Search folders that contain txt files that contains a specific word

Post by *Horst.Epp »

rockberto wrote: 2024-07-19, 15:11 UTC thanks everyone for the replies.
I solved it this way: I first searched for all the .txt files that contained the keyword. I renamed the extension of these files. Then I searched for only the folders that contained the files with the new extension and moved the folders. Then I put the right extension back on the .txt files
Clever solution :)
Windows 11 Home, Version 24H2 (OS Build 26100.3915)
TC 11.51 x64 / x86
Everything 1.5.0.1391a (x64), Everything Toolbar 1.5.2.0, Listary Pro 6.3.2.88
QAP 11.6.4.2.1 x64
User avatar
jonathanpoulin
Member
Member
Posts: 131
Joined: 2020-12-19, 12:09 UTC
Location: Saint-Marc-des-Carrières, QC Canada
Contact:

Re: Search folders that contain txt files that contains a specific word

Post by *jonathanpoulin »

2Fla$her
Yes. There a multiple ways to do it. The solutions JOUBE and rockberto proposed are one of those.
Thanks,
Jonathan Poulin
Fla$her
Power Member
Power Member
Posts: 2985
Joined: 2020-01-18, 04:03 UTC

Re: Search folders that contain txt files that contains a specific word

Post by *Fla$her »

2jonathanpoulin
No, those suggestions are not about what to do with the found folders. That's why I've pointed to a script that doesn't require extra steps.
Overquoting is evil! 👎
User avatar
petermad
Power Member
Power Member
Posts: 16009
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Search folders that contain txt files that contains a specific word

Post by *petermad »

2rockberto
Then I searched for only the folders that contained the files with the new extension...
How did you do this part - and come out with a list of folders?
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2985
Joined: 2020-01-18, 04:03 UTC

Re: Search folders that contain txt files that contains a specific word

Post by *Fla$her »

petermad wrote: 2024-07-20, 18:48 UTC How did you do this part - and come out with a list of folders?
FileMask.wdx, maybe?

FileMask.ini:

Code: Select all

[DirMask]
NEW=*.new
☑ Search in plugins:
filemask | DirMask | > | 0 | NEW [▾]
Overquoting is evil! 👎
User avatar
Stefan2
Power Member
Power Member
Posts: 4281
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: Search folders that contain txt files that contains a specific word

Post by *Stefan2 »

rockberto wrote: 2024-07-16, 08:48 UTC I can find all the text files that contain the specific word,
but I would like to have the list of folders and not of the files found
Search for the files
- in the search result, press Ctrl+C
- paste into a text editor with RegEx s&r
- to get
d:\Test ordner\d\TOTALCMD.CHM
d:\Test ordner\e\TOTALCMD.CHM



In the editor
- search for: (.+)\\.+
- replace with: \1 (or $1)
- to get
d:\Test ordner\d
d:\Test ordner\e



Save the result as C:\Temp\_myLoadlist.txt

(if you only wanted the list of the folders, you can stop here)



If you want to list the folders in TC to work with them somehow:

Create a user defined command in usercmd.ini
[em_LoadList]
cmd=LOADLIST C:\Temp\_myLoadlist.txt


Execute loadlist
- go to the "main folder"
- in TCs command line type em_loadlist and enter (later use Ctrl+E to re-execute)

(instead of a UDC, you may want to create a button with that command)


Work with the so found folders
- use Ctrl+T to duplicate the "search result"-tab
- now work with that new tab to do your things, use Ctrl+W to close that tab after work done
- for the next folder, open again a new tab from the "search result"-tab



HINT: once set up, you can always reuse it for the next case.


Needs "10.03.21 Release Total Commander 10.00 public beta 1" or newer.
01.11.20 Added: New internal command LOADLIST listfilename loads list of files/folders from text file.
There must be one name per line. If no path is provided, the current directory is assumed.
File details are retrieved automatically (32/64)



Instead of using LOADLIST, you also can use this older approach:
1. Make a search
with "Search for" left empty,
and "Search in" containing:
@c:\path to your\filelist.txt
(one file, folder or path per line)
2. Click on "Feed to listbox"

That way you get a search result from the current file system.
Next double the tab by using Ctrl+T so you can go back to the search result.
 

 
Post Reply