Search Gui: comments checkbox General tab

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Search Gui: comments checkbox General tab

Post by *hi5 »

In the current search gui there are several checkboxes:
[ ] RegEx [ ] Only search in selected directories/files
[ ] Everything [ ] Search archives
I would like to see a checkbox added for comments
[ ] Search comments
which would search in descript.ion and file.bbs files

This would provide a quick and easy toggle/shortcut avoiding the need to go to the plugins tab, and I think it would be a reasonable exception to make this "plugin" option available on the general tab.

Edit: AutoHotkey v2 script below viewtopic.php?p=442645#p442645
Last edited by hi5 on 2023-10-10, 19:16 UTC, edited 1 time in total.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: Search Gui: comments checkbox General tab

Post by *ghisler(Author) »

You can use Text search -> Plugins to search for comments.
Author of Total Commander
https://www.ghisler.com
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Search Gui: comments checkbox General tab

Post by *hi5 »

Thank you. No doubt I don't understand, but I don't seem to get the result I want or expect

I have a "file.txt" the comment is "login details",
I "search for:" login (so I don't search for TEXT, I search for "the file name" so to speak)
I expect the "[ ] search comments" option to show "file.txt" as result.

That currently doesn't work or does it?. If I search for text "login" it does seem to work but it also rather slow as it tries to find the "text" so it reads all files.

I just want to find the file(s) that matches the comment (I don't care about the content) - I can do this with the plugins tab but that is such a hassle (comparatively speaking)

This is my "Plugins" setup SearchCustomField in case that helps

Code: Select all

[SearchCustomField]
0exts=*test:*.*
0fields=[=tc.comment]
Edit: an example would be the TC program folder, try to find files that match "Parallel" for example, I would expect very fast results but instead it is rather a slow process as it reads all files to find the text.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Search Gui: comments checkbox General tab

Post by *AntonyD »

2hi5
pls, pay attention on my post in your "personal" topic F4MiniMenu (AHK)
https://www.ghisler.ch/board/viewtopic.php?p=423475#p423475
and one below it.

Concerning your current problem. As far I don't see such problem at all.
IF you know that all your special comments are in fact - part of some textual files
you definitely should find all *.txt files with searching inside them text pattern "login"
And no special comments or special comment files will help you find this file and this
information faster, imho.
#146217 personal license
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Search Gui: comments checkbox General tab

Post by *hi5 »

Just alt-F7 type "login", tick box search comments -> search -> results. Is much faster as alt-f7, plugins tab, select plugin, type text, search

The "problem" I'm trying to solve is that a file comment may have much more information than a file name provides, which is why I want to use the "search for file names" field to ALSO look for comments as I may not be aware the file(s) I'm looking has the "search" in its name or in its comment(s).
So it would be a "search in two fields" at once: NAME OR COMMENT. Now I would have to do two searches (one for name, if I don't find it, do one for comments)

I would find that logical, but one doesn't have to agree with this of course. But this is the suggestions section so I thought I put it out there.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Search Gui: comments checkbox General tab

Post by *AntonyD »

2hi5
I do not want to evaluate your judgment, but I can say that I do not understand what problem we are talking about.
After all, any comment, no matter what you write it about - it can only lie in some files predetermined by you!
Or a simple txt, or a descript.ion/bbs/.... I.e. there is no point in looking for a comment in the xlsx/pdf/... files.
So, if your goal is to find a comment on file X (it does not matter what this comment is about) - you are looking for ALL files that you use as commenters and inside them look for the substring "file name x". In the search results by double-pressing F3, you will quickly find what you are looking for.
So why enter any special comment box into the search dialog?
Last edited by AntonyD on 2022-11-06, 15:10 UTC, edited 1 time in total.
#146217 personal license
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Search Gui: comments checkbox General tab

Post by *hi5 »

All I know is "what" I search for, this can be the file name OR a comment.
I don't know in advance where the "what" I'm searching for is.

All I know is the "what".

So let's look the TC program folder, and all I know is that I want to look for "Parallel" files. I don't know or remember if there are actually files with "Parallel" in their name, or "Parallel" in their file comment.

If there would be a "Parallel.txt" file I will of course find it with a normal search.
But there isn't such a file - but in the file comments there are "Parallel" files (CGLPT64.SYS; CGLPT9X.VXD; CGLPTNT.SYS)

So now do I a normal search for "Parallel" -> no results. To be sure I need to do it again via the plugins (or open descript.ion) and search for comments with Parallel.

In my suggestion the results from a Parallel search with the "[ ] search comments" would be:

Parallel.txt
CGLPT64.SYS
CGLPT9X.VXD
CGLPTNT.SYS
Another Parallel file.docx

The three CGLP*.* files would be found based on the comment as "part of its name" so to speak (technically it isn't of course)
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Search Gui: comments checkbox General tab

Post by *white »

hi5 wrote: 2022-11-06, 10:49 UTC That currently doesn't work or does it?. If I search for text "login" it does seem to work but it also rather slow as it tries to find the "text" so it reads all files.
Disable the following options:
🔲 ANSI charset (Windows)
🔲 ASCII charset (DOS)
🔲 Unicode UTF16
🔲 UTF8
🔲 Office xml (docx, xlsx, odt etc)+EPUB
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Search Gui: comments checkbox General tab

Post by *hi5 »

OK, but that means the next text search I have to tick those boxes and then turn them on/off etc - not very efficient or user friendly which is what I'm after of course (yes I could script it, but this is a suggestion). There probably isn't much more to say about it.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
AntonyD
Power Member
Power Member
Posts: 1231
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Search Gui: comments checkbox General tab

Post by *AntonyD »

2hi5
But if you don't remember - you don't know WHAT you are looking for (from your example "Parallel" is just a file name or part of a comment line in a special file) - then you will not be able to interpret the results adequately!
Your example of a search result:
In my suggestion the results from a Parallel search with the "[ ] search comments" would be:

Parallel.txt
CGLPT64.SYS
CGLPT9X.VXD
CGLPTNT.SYS
Another Parallel file.docx
AND??? How to figure out in this case what is a real file and what is just a comment line ???
And such a result of searches will only worsen their readability.
I was looking for "something" that describes the "parallel", and they show me files whose names do not even approximately contain this.
And why would I be shown that?
#146217 personal license
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Search Gui: comments checkbox General tab

Post by *white »

hi5 wrote: 2022-11-06, 15:16 UTC OK, but that means the next text search I have to tick those boxes and then turn them on/off etc
You can create a saved search (put ">" in Search in field and put some text in the Find text field) and use the command LOADSEARCH in a button for example. But there is a bug causing the ANSI checkbox to be enabled when using LOADSEARCH command (not when loading the search manually). I will create a bug report.
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Search Gui: comments checkbox General tab

Post by *hi5 »

Yes I would be able to, I feed the results to the listbox and take it from there which may be opening/moving/deleting/quick view - It doesn't concern me if it is a file name or comment (although file name is obvious). It would only show "CGLP*.*" if I use the "comments checkbox" of course so there would be no confusion as to why these files are there (just like I could do now with the plugin option).

I just want a quick method to find them.
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Search Gui: comments checkbox General tab

Post by *hi5 »

white wrote: 2022-11-06, 15:50 UTCYou can create a saved search (put ">" in Search in field and put some text in the Find text field) and use the command LOADSEARCH in a button for example.
I appreciate the suggestion(s) but it is not what I'm after, I just want to keep the alt-f7, type, search, hit enter, results-workflow. But I'm glad to see this request leads to a bug report :mrgreen:
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Search Gui: comments checkbox General tab

Post by *white »

Bug report is here.
hi5
Power Member
Power Member
Posts: 551
Joined: 2012-11-03, 11:35 UTC
Contact:

Re: Search Gui: comments checkbox General tab

Post by *hi5 »

To illustrate how it would work I've created a basic AutoHotkey v2 script (code below) - v2 is also available on the AutoHotkey website https://www.autohotkey.com/download/

You setup a button, start menu, or command:

Command: path-to\file-name-and-comment-search.ahk
Parameter: %P

If you started the script and search for cat and your active panel would have the following files in it:

namecomment
cat.jpg Tigger
another cat.jpg
dog.jpg Fenton
img123.jpg Cat


These results will be loaded into current panel:

c:\path-to\cat.jpg
c:\path-to\another cat.jpg
c:\path-to\img123.jpg

That is what I want and I can now continue with whatever task at hand, so having a checkbox as outlined in the first post would make it quick & easy to access just like "text search" for example.

Script

Code: Select all

/*
File Name and Comment Search

Call from TC (button, start, command):

Command:   path-to\file-name-and-comment-search.ahk
Parameter: %P

Forum: https://www.ghisler.ch/board/viewtopic.php?t=77941

*/

#Requires AutoHotkey v2.0+
#SingleInstance force

Try
	TraySetIcon("c:\totalcmd\TOTALCMD.EXE")
Catch
	TraySetIcon("shell32.dll", 23) ; search icon

Try
	path:=A_Args[1]
Catch
	{
	 MsgBox("Missing path parameter (Pass on %P from TC to Script)","File Name and Comment Search",48)
	 ExitApp
	}

IB := InputBox("Search for:", "Find Files: [" path "]", "w840 h90")
if IB.Result = "Cancel"
	ExitApp

FileList:=""  ; Initialize to be blank.

Loop Files, path "\*.*"
	{
	 If InStr(A_LoopFilename,IB.value)
	 	FileList .= A_LoopFileFullPath "`n"
	}

If FileExist(path "\descript.ion")
	{
	 comments:=FileRead(path "\descript.ion")

	 q:=Chr(34)

	 Loop parse, comments, "`n", "`r"
		{
		 If InStr(A_LoopField,IB.value)
			{
			 Result:=GetFileComment(A_LoopField)["FileName"]
			 FileList .= path Trim(Result," `t") "`n"
			}
		}
	}

Try
	FileDelete A_ScriptDir "\$$results.txt"
FileAppend FileList, A_ScriptDir "\$$results.txt"

Run "c:\totalcmd\TOTALCMD.EXE /O LOADLIST:" A_ScriptDir "\$$results.txt"
Sleep 1000
Try
	FileDelete A_ScriptDir "\$$results.txt"
ExitApp

; v2 version, v1 https://github.com/hi5/qvd/blob/main/lib/Description.ahk
GetFileComment(line)
	{
	 static q:=Chr(34)
	 if (SubStr(line,1,1) = q)
		{
		 FileName:=Trim(SubStr(line,1,InStr(line,q,,2)),q)
		 Comment:=Trim(SubStr(line,InStr(line,q,,2)),q " ")
		}
	 else
		{
		 FileName:=Trim(SubStr(line,1,InStr(line," ")))
		 Comment:=SubStr(line,InStr(line," ")+1)
		}

	 if InStr(Comment,Chr(4)) ; we need to remove EOT (Chr(4) and Â)
		{
		 Comment:=SubStr(Comment,1,StrLen(Comment)-2)
		}
	 obj := Map()
	 obj["FileName"]:=FileName
	 obj["Comment"]:=Comment
	 Return obj
	}
F4MiniMenu (Forum) - Open selected file(s) from TC in defined editor(s) - A (minimalistic) clone of F4Menu
Source at GitHub (AutoHotkey). TCSyncComments (copy file comments)
Post Reply