Open Everything GUI results with TC LOADLIST

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

2Ovg
Ovg wrote: 2021-10-21, 10:22 UTC Sorry, minor update
Please change line 111 to

Code: Select all

If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")
For Users: comments shouldn't starts with "\\" :wink:
tuska wrote: 2021-10-21, 13:35 UTC Now I'll do another quick test with this parameter:

Code: Select all

If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")
This test was also SUCCESSFUL! :)
Thank you again!
2021-10-21_1222_HorstEpp&Ovg_tuska_MinorUpdate_UseInstanceBLANK_TESTS-with-3-instances.ahk

Code: Select all

; Transfer Everything GUI results to TC
; Authors: Horst.Epp & Ovg
; Last modified: 20.10.2021 (Added option UseInstance) .... 21.10.2021: If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")

; https://www.ghisler.ch/board/viewtopic.php?t=75439 ...... Open Everything GUI results with TC LOADLIST
; https://www.ghisler.ch/board/viewtopic.php?t=75417 ...... LOADLIST command and UTF8 file lists
; https://www.voidtools.com/forum/viewtopic.php?f=4&t=10594 Send ResultsList to Total Commander

; Build AutoHotkey_L
; Build x64
; Build Kill=true
; Build Zip=false
; Build Run=true

#NoEnv
;#Persistent
#SingleInstance Force
SetBatchLines, -1

; Create / read .ini file settings
SetTitleMatchMode, RegEx
iniFile := RegExReplace(A_ScriptFullPath, "(ahk|exe)$", "ini")

if not (FileExist(iniFile)) {
    iniContent :="
    (( LTrim
        [General]
	; DestinationFile
        ;    Where to save the output (full path to DestinationFile.txt)
        ; EverythingColumnPositions (Default: 2,1)
	;    The columns 'Name' and 'Path'  (must be visible in the Everything GUI)
        ;    The first value is the position of the 'Path' column
        ;    The second value is the position of the 'Name' column
	; CloseEverything (Default 1 for yes)
	;    Should Everything GUI window be closed after transfering results to TC
	; UseInstance (empty for default instance)
        ;    Name of the Everything instance to be used for closing the GUI

; The contents of the following lines must be adjusted if necessary, e.g. path and parameter adjustments.
;********************************************************************************************************
        DestinationFile = D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt
        EverythingColumnPositions=2,1
        AddEndSlash = 1
        CloseEverything = 0
        UseInstance =
        Everything = C:\Tools\Everything\Everything64.exe
        TotalCmd = D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE
;********************************************************************************************************

    )"
    FileAppend, % iniContent, % iniFile, UTF-16
}
IniRead, DestinationFile, % iniFile, General, DestinationFile, %A_Space%
IniRead, EverythingColumnPositions, % iniFile, General, EverythingColumnPositions, 2`,1

IniRead, AddEndSlash, % iniFile, General, AddEndSlash, 1
IniWrite, %AddEndSlash%, % iniFile, General, AddEndSlash
IniRead, CloseEverything, % iniFile, General, CloseEverything, 1
IniWrite, %CloseEverything%, % iniFile, General, CloseEverything
IniRead, UseInstance, % iniFile, General, UseInstance, %A_Space%
IniWrite, %UseInstance%, % iniFile, General, UseInstance

IniRead, Everything, % iniFile, General, Everything, "C:\Tools\Everything\Everything64.exe"
IniRead, TotalCmd, % iniFile, General, TotalCmd, "D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE"

DestinationFile           := ResolveEnvVars(DestinationFile)
EverythingColumnPositions := StrReplace(EverythingColumnPositions, " ")

; Force error if none is given (or path doesn't exist)
SplitPath, DestinationFile, , dstPath
if (DestinationFile = "" || !InStr(FileExist(dstPath), "D")) {
    Msgbox, 16, Fatal error, Destination file definition is missing or illegal named !
    Return
}
if (EverythingColumnPositions = "" || !InStr(EverythingColumnPositions, ",")) {
    EverythingColumnPositions := "2,1"
}

columnArray := StrSplit(EverythingColumnPositions, ",")

hWnd := WinExist("ahk_exe Everything(?:\d\d)*\.exe")

if hWnd
{
  ControlGet, winContent, List, , SysListView321, % "ahk_id" hWnd

  if (winContent)
  {
    fullContent := ""
;   Loop over row(s)
    Loop, Parse, winContent, `n
    {
      rowID := A_Index
      path  := ""
      name  := ""
      full  := ""
      Bad := 2
;     Loop over column(s)
      Loop, Parse, A_LoopField, % A_Tab
      {
        colID   := A_Index
        content := A_LoopField
        If (colID > columnArray[1] And colID > columnArray[2])
        {
          Break
        }
        Else
        {
          If (colID = columnArray[1])
          {
            If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")
            {
              Break
            }
            path := content
            Bad -= 1
            If !RegExMatch(path,"\\$")
            {
              path := path . "\"
            }
          }
          Else if (colID = columnArray[2])
          {
            If content is Space
            {
              Break
            }
            name := content
            Bad -= 1
          }
        }
      }
      If (Bad == 0)
      {
        full        := path . name
        If InStr(FileExist(full), "D")
        {
          if (AddEndSlash == 1)
          {
            if !RegExMatch(full,"\\$")
            {
              full := full . "\"
            }
          }
          Else
          {
            If RegExMatch(full,"\\$")
            {
              full := SubStr(full,1,StrLen(full)-1)
            }
          }
        }
        fullContent .= full "`n"
      }
    }
    fullContent := RegExReplace(fullContent,"\R$","")
    If (FileExist(DestinationFile))
      FileDelete, % DestinationFile

        FileAppend, % fullContent, % DestinationFile, UTF-16

	DestinationDir := SubStr(DestinationFile,1,InStr(DestinationFile, "\",,-1))
	Run %TotalCmd% /O /T /S %DestinationDir%
	If (CloseEverything == 1) {
             run %Everything% -instance "%UseInstance%" -close
	}
    }
    Else
;   Empty search result
    {
      Msgbox, 16,, Search result is Empty, Nothing to do ...
    }
; No Everything window visible
} Else {
    Msgbox, 16, Fatal error, Everything window does not exist!
}
SetTitleMatchMode, 1
return

; ==================================
; = GOTO: FUNCTIONS - ResolveEnvVars
; ==================================
; http://www.autohotkey.com/board/topic/40115-func-envvars-replace-environment-variables-in-text/#entry310601
ResolveEnvVars(str) {
    if sz := DllCall("ExpandEnvironmentStrings", "uint", &str, "uint", 0, "uint", 0)
    {
        VarSetCapacity(dst, A_IsUnicode ? sz * 2 : sz)
        if DllCall("ExpandEnvironmentStrings", "uint", &str, "str", dst, "uint", sz)
            return dst
    }
    return str
}
2021-10-21_1222_HorstEpp&Ovg_tuska_MinorUpdate_UseInstanceBLANK_TESTS-with-3-instances.ini

Code: Select all

[General]
DestinationFile = D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt
EverythingColumnPositions=2,1
AddEndSlash =1
CloseEverything =0
UseInstance =
Everything = C:\Tools\Everything\Everything64.exe
TotalCmd = D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE
2021-10-21_1222_Ovg_tuska_MinorUpdate_Comments-with-doublebackslash.ini
A line beginning with '\\' that is used as a comment line is translated with the code:

Code: Select all

If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")
NOT taken into account and the script therefore does not issue an error message.

Code: Select all

[General]
DestinationFile = D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt
EverythingColumnPositions=2,1
AddEndSlash =1
CloseEverything =0
\\ CloseEverything = 1 is also possible and closes the Everything-window
UseInstance =
Everything = C:\Tools\Everything\Everything64.exe
TotalCmd = D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE

Windows 10 Pro (x64) Version 21H1 (OS build 19043.1288)
TC 10.00 x64 | 'Everything' 1.5.0.1280a (x64)
User avatar
Horst.Epp
Power Member
Power Member
Posts: 6450
Joined: 2003-02-06, 17:36 UTC
Location: Germany

Re: Open Everything GUI results with TC LOADLIST

Post by *Horst.Epp »

tuska wrote: 2021-10-21, 13:35 UTC Remark:
What do you think about using CloseEverything = 0 as default setting?

Especially users who use the script for the first time would have the advantage
- with regard to comparing the search result in EV and TC -
that they do not have to perform the search query again in EV.

On the other hand, if there is no error message, and the search result is not empty,
then the transfer should have been carried out properly.
I prefer close as default for the following reasons:
Only long running Everything searches will have a benefit of not closing the search.
A simple search is always fast repeated by using the search history.
I often do many searches and all results are open at the same time in different results tabs in TC.
If I would let the Everything GUIs open this produces many useless open GUIs in the background.
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
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Horst.Epp wrote: 2021-10-21, 15:21 UTC
tuska wrote: 2021-10-21, 13:35 UTC Remark:
What do you think about using CloseEverything = 0 as default setting?

Especially users who use the script for the first time would have the advantage
- with regard to comparing the search result in EV and TC -
that they do not have to perform the search query again in EV.

On the other hand, if there is no error message, and the search result is not empty,
then the transfer should have been carried out properly.
I prefer close as default for the following reasons:
Only long running Everything searches will have a benefit of not closing the search.
A simple search is always fast repeated by using the search history.
I often do many searches and all results are open at the same time in different results tabs in TC.
If I would let the Everything GUIs open this produces many useless open GUIs in the background.
Thanks for your detailed answer.
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

2tuska

I meant comments in your files, not in the body of the script and in AHK script comments start with ; :mrgreen:
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Ovg wrote: 2021-10-21, 10:22 UTC Sorry, minor update
Please change line 111 to

Code: Select all

If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")
For Users: comments shouldn't starts with "\\" :wink:
Ovg wrote: 2021-10-21, 18:12 UTC 2tuska
I meant comments in your files, not in the body of the script and in AHK script comments start with ; :mrgreen:
... says a professional to an amateur user and shows him the Mr. Green right away. :wink:
Please provide more precise information in future. Thank you!

But I can assure you that this test was also SUCCESSFUL! :)
Tested again with 3 instances: MAIN, PRIVATE, PRIVAT.
2021-10-21_1222_Ovg_tuska_MinorUpdate_Comments-with-doublebackslash-in-files.ini

Code: Select all

[General]
DestinationFile = D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\EV-Results\EV-Results.txt
EverythingColumnPositions=2,1
AddEndSlash =1
CloseEverything =0
UseInstance =
Everything = C:\Tools\Everything\Everything64.exe
TotalCmd = D:\Daten\Programme\TotalCommander\TCD_USB-Stick\TC32-64USB\TOTALCMD64.EXE
Test.doc -> Properties -> Comments:

Code: Select all

\\ Dies ist ein Test.
Test1.doc -> Properties -> Comments:

Code: Select all

\\Dies ist Test2.
Excel.xltm -> Properties -> Comments:

Code: Select all

\\Test comment in .xltm
I hope the good test results will continue, because I still have a few tests planned.
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

tuska wrote: 2021-10-18, 22:11 UTC 3. In my opinion, it is advisable to at least compare the search result
    in Total Commander with the search result in Everything in the status bar.
I made a suggestion in this regard in the Everything Forum, and I hope that this suggestion will be implemented.
Everything-1.5.0.1281a - 21.10.2021 --> Added status bar format customization. | Status Bar Format
Proposal: Search results in status bar, e.g. xx objects (xx files, xx directories)

I don't even know why it took so long this time (14.10. - 21.10.) :)
for my suggestion to be implemented by the author of Everything,
because I remember that another suggestion was already implemented the next day :D .
Everything 1.5.0.1281a - Example1 - Status bar: 0 objects (0 files, 0 folders)
In Everything, type in the following search and press ENTER

Code: Select all

/statusbar_format=#if:<#result-count:==1,1 object,#TEXT:<#result-count:,#,###> objects> (#TEXT:<#file-result-count:,#,###> files, #TEXT:<#folder-result-count:,#,###> folders)
If successful, you should see the following in the status bar for a few seconds
statusbar_format=#if:<#result-count:==1,1 object,#TEXT:<#result-count:,#,###> objects> (#TEXT:<#file-result-count:,#,###> files, #TEXT:<#folder-result-count:,#,###> folders)
The status bar then shows the following: 0 objects (0 files, 0 folders)
Everything 1.5.0.1281a - Example2 - Status bar: 0 objects (0 folders, 0 files)
In Everything, type in the following search and press ENTER

Code: Select all

/statusbar_format=#if:<#result-count:==1,1 object,#TEXT:<#result-count:,#,###> objects> (#TEXT:<#folder-result-count:,#,###> folders, #TEXT:<#file-result-count:,#,###> files)
If successful, you should see the following in the status bar for a few seconds
statusbar_format=#if:<#result-count:==1,1 object,#TEXT:<#result-count:,#,###> objects> (#TEXT:<#folder-result-count:,#,###> folders, #TEXT:<#file-result-count:,#,###> files)
The status bar then shows the following: 0 objects (0 folders, 0 files)
Everything 1.5.0.1281a - Example3 - Status bar: (0 folders, 0 files) 0 objects
In Everything, type in the following search and press ENTER

Code: Select all

/statusbar_format=(#TEXT:<#folder-result-count:,#,###> folders, #TEXT:<#file-result-count:,#,###> files) #if:<#result-count:==1,1 object,#TEXT:<#result-count:,#,###> objects>
If successful, you should see the following in the status bar for a few seconds
statusbar_format=(#TEXT:<#folder-result-count:,#,###> folders, #TEXT:<#file-result-count:,#,###> files) #if:<#result-count:==1,1 object,#TEXT:<#result-count:,#,###> objects>
The status bar then shows the following: (0 folders, 0 files) 0 objects
Enjoy! :D
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

tuska wrote: 2021-10-21, 20:08 UTC ... says a professional to an amateur user and shows him the Mr. Green right away. :wink:
Sorry, I did not want to offend you or anyone and I am not a professional programmer ...
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Ovg wrote: 2021-10-22, 08:03 UTC
tuska wrote: 2021-10-21, 20:08 UTC ... says a professional to an amateur user and shows him the Mr. Green right away. :wink:
Sorry, I did not want to offend you or anyone and I am not a professional programmer ...
No problem, let's forget that.
But I am firmly convinced that you are well on your way to becoming a professional programmer. :D
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Back again briefly at the difference of 1 folder (with/without backslash) -> Differences (clarified)
concerning the search result in Everything and Total Commander.

I would like to refer to this detailed list.
under topic "Add trailing backslash to name for folders"

The following is broken down here:

Code: Select all

Everything: Search box, Display, Status bar, Shortcuts, Parameter settings.
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Hi,
What is actually considered the latest version of the script now?

Code: Select all

First post: If !RegExMatch(content,"i)^[a-z]:|\\\.*?\\")	21.10.2021 11:38
Ovg post  : If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")	21.10.2021 12:22
Thanks!
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

tuska wrote: 2021-10-22, 14:03 UTC Hi,
What is actually considered the latest version of the script now?

Code: Select all

First post: If !RegExMatch(content,"i)^[a-z]:|\\\.*?\\")	21.10.2021 11:38
Ovg post  : If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")	21.10.2021 12:22
Thanks!
The second one
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

Ovg wrote: 2021-10-22, 14:06 UTC
tuska wrote: 2021-10-22, 14:03 UTC Hi,
What is actually considered the latest version of the script now?

Code: Select all

First post: If !RegExMatch(content,"i)^[a-z]:|\\\.*?\\")	21.10.2021 11:38
Ovg post  : If !RegExMatch(content,"i)^(?:[a-z]:|\\\.*?\\)")	21.10.2021 12:22
Thanks!
The second one
Thanks!
Then I will get back to work...
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

tuska wrote: 2021-10-22, 13:32 UTC Back again briefly at the difference of 1 folder (with/without backslash) -> Differences (clarified)
concerning the search result in Everything and Total Commander.

I would like to refer to this detailed list.
under topic "Add trailing backslash to name for folders"

The following is broken down here:

Code: Select all

Everything: Search box, Display, Status bar, Shortcuts, Parameter settings.
If I understood you correctly , this difference is because script ignores entries in EV list with empty paths such N:\ or N: and so on
because TC can't find such entries while loading result file.
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
User avatar
tuska
Power Member
Power Member
Posts: 3741
Joined: 2007-05-21, 12:17 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *tuska »

2Ovg
Sorry for the late reply.
Real life had caught up with me.
Ovg wrote: 2021-10-22, 14:10 UTC If I understood you correctly ,
this difference is because script ignores entries in EV list with empty paths such N:\ or N: and so on
because TC can't find such entries while loading result file.
No, the script takes what it can get from Everything and documents it in the EV-Results.txt.
Total Commander takes what it can get with LOADLIST or what can be processed(!) and outputs it in the search result.

Let me explain the difference with the following example (the same applies to drive N):

Code: Select all

Everything Search box    Everything - Search result		Total Commander - Search result      EV-Results.txt - diff.
D:\Daten\WINWORD\	 98 objects (88 files, 10 folders)	88 file(s), 10 / 10 dir(s)	     -
D:\Daten\WINWORD	 99 objects (88 files, 11 folders)	88 file(s), 11 / 11 dir(s)	     D:\Daten\WINWORD\
In principle, a ' \ ' backslash(!) should always be entered at the end [of the path] for folders in Everything,
so that the search results for folders in EV and TC match!


Conclusion:
  1. To ensure that the search result in Everything and TC match,
    a backslash must always be specified at the end [of the path] for folders, regardless of whether
    folder_append_path_separator=0 (default) ... -OR- ... folder_append_path_separator=1 (default) is set.
     
  2. Otherwise the folder "D:\Daten\WINWORD\" - the contents of which were searched for in Everything -
    will also be displayed (additionally) in Total Commander's search results!
     
  3. If someone does not mind that the search result between EV and TC differs by 1 folder,
    then the backslash at the end [of the path] of folders does NOT have to be specified.
    I am not aware of any disadvantage and the difference of 1 folder only came to my attention during the tests.
     
  4. A user in the Everything Forum explained this expertly: https://www.voidtools.com/forum/viewtopic.php?p=40529#p40529
    raccoon wrote:If you add the closing backslash at the end of your path query, the drive/folder object itself should no longer appear.
    Y:\
    (The colon is part of the object name, the same way the dot before a file extension is.
    Maybe someday @void will allow AltStream names to appear in the full index, which also uses colon as a delimiter.
    As in Y:\Everything-1.5.0.1280a.x64.zip:Zone.Identifier which is a valid object name.)
User avatar
Ovg
Power Member
Power Member
Posts: 756
Joined: 2014-01-06, 16:26 UTC

Re: Open Everything GUI results with TC LOADLIST

Post by *Ovg »

Aha, thanks, I see now

And you shouldn't apologize.... :D
It's impossible to lead us astray for we don't care even to choose the way.
#259941, TC 11.01 x64, Windows 7 SP1 x64
Post Reply