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:
name | comment |
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
}