Feature Request: show hardlinked files of selected files

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Anselm
Junior Member
Junior Member
Posts: 31
Joined: 2013-09-17, 17:06 UTC

Feature Request: show hardlinked files of selected files

Post by *Anselm »

idea:
select some files and press a key combination. As a result in the active panel or (better) in the 2nd panel all the files are listed which are hard linked to the selected files.

maybe this also useful for directories and symbolic links.
Fla$her
Power Member
Power Member
Posts: 2294
Joined: 2020-01-18, 04:03 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Fla$her »

2Anselm
Try this:
.vbs + ln + TCFS2

Code: Select all

'——————————————————————————— VBS ———————————————————————————
' Purpose:  Display list of hard links to the selected files
' Condition: Create em_LOADLIST with LOADLIST/%A (1/2 field)
' Parameters: %WL [/t] [/n]
' /t — show in target panel
' /n — show in new tab

Option Explicit
'————————————— Paths to ln and TCFS2 utilities —————————————
Const LN    = """%COMMANDER_PATH%\Utils\ln\ln.exe"""
Const TCFS2 = """%COMMANDER_PATH%\Utils\TCFS2\TCFS2.exe"""
'——————————————————————————————————————— Author: Flasher © —
Dim A, FSO, WSS, List, L, F, Text, T, E
Set A = WSH.Arguments : If A.Count = 0 Then WSH.Quit
Set FSO = CreateObject("Scripting.FileSystemObject")
L = FSO.GetSpecialFolder(2) & "\" & FSO.GetTempName
Set WSS = CreateObject("WScript.Shell")
Set List = FSO.OpenTextFile(A(0),,,-1)
Do: F = List.ReadLine
   If Right(F, 1) <> "\" Then _
   WSS.Run "%ComSpec% /q/c """ & LN & " --list """ & F & """>>""" & L & """""", 0, 1
Loop Until List.AtEndOfStream : List.Close : Set List = Nothing
If FSO.FileExists(L) Then
   Text = FSO.OpenTextFile(L).ReadAll
   With New RegExp
      .Pattern = "^l..[.0-9]+\r\n|\r\nl..[.0-9]+"
      .Global = 1: Text = .Replace(Text, "")
   End With
   If A.Named.Exists("t") Then T = "tcm(4006) "
   If A.Named.Exists("n") Then T = "msg($0B,0) " & T & "tcm(3001) " : E = " msg($0B,1) redraw()"
   With FSO.OpenTextFile(L, 2) .Write Text : .Close : End With
   WSS.Run TCFS2 & " /ef """ & T & "tem(`em_LOADLIST " & L & "`)" & E & """",, 1
   FSO.DeleteFile L, 1
End If
Set FSO = Nothing : Set WSS = Nothing
Last edited by Fla$her on 2022-05-23, 20:07 UTC, edited 3 times in total.
Overquoting is evil! 👎
Anselm
Junior Member
Junior Member
Posts: 31
Joined: 2013-09-17, 17:06 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Anselm »

thanks @Fla$her

i have to put ln and TCFS2 to the folder used in the script.
1. How do i integrate the vbs script to TC?
2. How can i configure:
' Condition: Create em_LOADLIST with LOADLIST/%A (1/2 field)
' Parameter: %WL
Fla$her
Power Member
Power Member
Posts: 2294
Joined: 2020-01-18, 04:03 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Fla$her »

2Anselm
Don't you see " Paths to ln and TCFS2 utilities " in the script header? Set your paths.
1-2. You should know how to make em_ commands and hotkeys for them. See the help.

Example:

em_ListHDlinksToSelFiles (+ hotkey in the Misc. settings page):
Command: %COMMANDER_PATH%\Scripts\ListHDlinksToSelFiles.vbs
Parameters: %WL

em_LOADLIST:
Command: LOADLIST
Parameters: %A
Overquoting is evil! 👎
Anselm
Junior Member
Junior Member
Posts: 31
Joined: 2013-09-17, 17:06 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Anselm »

Thank you, i still have trouble.
Using the hotkey i am getting an error:

Code: Select all

< Error! >

File not found!
C:\Users\Username\AppData\Local\Temp\rad67C8B.tmp
My configuration:

no changes in ListHDlinksToSelFiles.vbs script.

location of ListHDlinksToSelFiles.vbs, ln, TCFS2:

Code: Select all


C:\TOTALCMD
|   ...
|   
+---Scripts
|       ListHDlinksToSelFiles.vbs
|       
\---Utils
    |   
    +---ln
    |   |   ln.exe
    |   |   ...   
    |               
    +---TCFS2
    |       Readme.txt
    |       TCFS2.Core.ini
    |       TCFS2.exe
    |       TCFS2.ini
1.

Configuration --> Options... --> Misc.:
  • hotkey: Alt+F7
    Click the button with the magnifying glass
    choose category: usercmd.ini --> New...
    new command name (em.xyz): em_ListHDlinksToSelFiles
    Change user command: em_ListHDlinksToSelFiles
    • command: %COMMANDER_PATH%\Scripts\ListHDlinksToSelFiles.vbs
      Parameters: %WL
    press button: OK
    press button: OK
    press button with the green checkmark
Configuration --> Options... --> Misc.:
  • Alias: em_LOADLIST
    Click the button with the magnifying glass
    new command name (em.xyz): em_LOADLIST
    • command: LOADLIST
      Parameters: %A
    press button: OK
    press button: OK
    press button with the green checkmark
Fla$her
Power Member
Power Member
Posts: 2294
Joined: 2020-01-18, 04:03 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Fla$her »

2Anselm
Does TC or script show this error? Was there a line number shown there?
What bit depth do ln.exe and your Windows have?
You may have selected a large array of files.
Add ,, 1 to the end of line 28.
Overquoting is evil! 👎
Anselm
Junior Member
Junior Member
Posts: 31
Joined: 2013-09-17, 17:06 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Anselm »

2Fla$her

i think the filename rad67C8B.tmp is wrong, the existing one is:
CMDEE84.tmp

Do you have an idea what is wrong?
Anselm
Junior Member
Junior Member
Posts: 31
Joined: 2013-09-17, 17:06 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Anselm »

Fla$her wrote: 2022-05-23, 17:04 UTC 2Anselm
Does TC or script show this error? Was there a line number shown there?
What bit depth do ln.exe and your Windows have?
You may have selected a large array of files.
Add ,, 1 to the end of line 28.
C:\totalcmd\Utils\ln\ln.exe


TC shows the error
I only selected one file:

The content of the tmp file is:
c:\test\test

Code: Select all

C:\WINDOWS\system32>fsutil.exe hardlink list "c:\test\test
\test\a\test2
\test\test
Fla$her
Power Member
Power Member
Posts: 2294
Joined: 2020-01-18, 04:03 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Fla$her »

2Anselm
You're not answering my questions.
Fla$her wrote: 2022-05-23, 17:04 UTCWas there a line number shown there?
What bit depth do ln.exe and your Windows have?

Fla$her wrote: 2022-05-23, 17:04 UTCAdd ,, 1 to the end of line 28.
Did you make the addition in the code?

Anselm wrote: 2022-05-23, 15:32 UTChotkey: Alt+F7
Why kill the search dialog call? :?
Overquoting is evil! 👎
Anselm
Junior Member
Junior Member
Posts: 31
Joined: 2013-09-17, 17:06 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Anselm »

Fla$her wrote: 2022-05-23, 17:04 UTCWas there a line number shown there?
What bit depth do ln.exe and your Windows have?
I copied the error text word by word. There is no line number shown.

What do you mean with bit depth? I though you mean folder depth.
Fla$her wrote: 2022-05-23, 17:04 UTCAdd ,, 1 to the end of line 28.
Did you make the addition in the code?

Sorry i did not see this.

:D yes, it works with this change. Thank you, very nice.

Anything i can do to show the result in the "non active" panel?



Anselm wrote: 2022-05-23, 15:32 UTChotkey: Alt+F7
Why kill the search dialog call? :?

which search dialog? It makes it so complicated, because i am not able to upload screen shots.
Anselm
Junior Member
Junior Member
Posts: 31
Joined: 2013-09-17, 17:06 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Anselm »

Fla$her wrote: 2022-05-23, 17:04 UTC 2Anselm
What bit depth do ln.exe and your Windows have?
Ah, now i get it. Both are 64 bit.
Fla$her
Power Member
Power Member
Posts: 2294
Joined: 2020-01-18, 04:03 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Fla$her »

Anselm wrote: 2022-05-23, 18:38 UTC :D yes, it works with this change. Thank you, very nice.
Good. You’re welcome. )
Anselm wrote: 2022-05-23, 18:38 UTCAnything i can do to show the result in the "non active" panel?
Added two keys to the parameters.
Anselm wrote: 2022-05-23, 15:32 UTCwhich search dialog?
Alt+F7 brings up "Find Files" dialog by default. You didn't know about this? Execute cm_Keyboard from TC command line.
Overquoting is evil! 👎
Anselm
Junior Member
Junior Member
Posts: 31
Joined: 2013-09-17, 17:06 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Anselm »

2Fla$her
Fla$her wrote: 2022-05-23, 19:27 UTC
Anselm wrote: 2022-05-23, 15:32 UTCwhich search dialog?
Alt+F7 brings up "Find Files" dialog by default. You didn't know about this? Execute cm_Keyboard from TC command line.
Yes and no. I was aware TC does not warn me if i am overriding existing TC default keys.
I was not aware ALT+F7 is associated with "find files". Thank you for the hint and the hint to key mapping help.
Does the TOTALCMD.CHM also exist in English? I would like to know the English terms to get a better understanding of the naming of the cm_ commands.

F11 and F12 are not occupied, but does not work.

I will switch to ALT+digit, hopefully they are not occupied.

Fla$her wrote: 2022-05-23, 19:27 UTC
Anselm wrote: 2022-05-23, 18:38 UTCAnything i can do to show the result in the "non active" panel?
Added two keys to the parameters.
I am inexperienced with vbs and parameter evaluation in vbs. So I hard coded it to your vbs, adding to line 28:

Code: Select all

   WSS.Run TCFS2 & " /ef ""tem(cm_FocusTrg)""",, 1  
So i changed your code to:

Code: Select all

'——————————————————————————— VBS ———————————————————————————
' Purpose:  Display list of hard links to the selected files
' Condition: Create em_LOADLIST with LOADLIST/%A (1/2 field)
' Parameter: %WL

Option Explicit
'————————————— Paths to ln and TCFS2 utilities —————————————
Const LN    = """%COMMANDER_PATH%\Utils\ln\ln.exe"""
Const TCFS2 = """%COMMANDER_PATH%\Utils\TCFS2\TCFS2.exe"""
'——————————————————————————————————————— Author: Flasher © —
Dim FSO, WSS, List, L, F, Text
If WSH.Arguments.Count = 0 Then WSH.Quit
Set FSO = CreateObject("Scripting.FileSystemObject")
L = FSO.GetSpecialFolder(2) & "\" & FSO.GetTempName
Set WSS = CreateObject("WScript.Shell")
Set List = FSO.OpenTextFile(WSH.Arguments(0),,,-1)
Do: F = List.ReadLine
   If Right(F, 1) <> "\" Then _
   WSS.Run "%ComSpec% /q/c """ & LN & " --list """ & F & """>>""" & L & """""", 0, 1
Loop Until List.AtEndOfStream : List.Close : Set List = Nothing
If FSO.FileExists(L) Then
   Text = FSO.OpenTextFile(L).ReadAll
   With New RegExp
      .Pattern = "^l..[.0-9]+\r\n|\r\nl..[.0-9]+"
      .Global = 1: Text = .Replace(Text, "")
   End With
   With FSO.OpenTextFile(L, 2) .Write Text : .Close : End With
   WSS.Run TCFS2 & " /ef ""tem(cm_FocusTrg)""",, 1  
   WSS.Run TCFS2 & " /ef ""tem(`em_LOADLIST " & L & "`)""",, 1
   FSO.DeleteFile L, 1
End If
Set FSO = Nothing : Set WSS = Nothing
content of usercmd.ini is:

Code: Select all

[em_ListHDlinksToSelFiles]
button=
cmd=%COMMANDER_PATH%\Scripts\ListHDlinksToSelFiles.vbs
param=%WL
[em_LOADLIST]
button=
cmd=LOADLIST
param=%A
thank you very much Fla$her
Last edited by white on 2022-05-24, 13:59 UTC, edited 1 time in total.
Reason: added: 2Fla$her
User avatar
white
Power Member
Power Member
Posts: 4615
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: Feature Request: show hardlinked files of selected files

Post by *white »

Moderator message from: white » 2022-05-24, 13:59 UTC

Removed duplicate post.
Added 2Fla$her to previous post (because author was probably trying to do that).
Fla$her
Power Member
Power Member
Posts: 2294
Joined: 2020-01-18, 04:03 UTC

Re: Feature Request: show hardlinked files of selected files

Post by *Fla$her »

Anselm wrote: 2022-05-24, 08:05 UTCDoes the TOTALCMD.CHM also exist in English?
What language do you speak yourself? English and German help are included in the TC distribution kit by default.
Anselm wrote: 2022-05-24, 08:05 UTCI will switch to ALT+digit, hopefully they are not occupied.
It's voluntary, of course, but I would choose a letter (L or H) instead of a digit.
Anselm wrote: 2022-05-24, 08:05 UTCI am inexperienced with vbs and parameter evaluation in vbs.
This has the same relation to vbs as to any other parameterized program. Is it really so difficult to specify %WL /t or %WL /t /n in the parameters?
Anselm wrote: 2022-05-24, 08:05 UTCSo I hard coded it to your vbs, adding to line 28:
Actually, tem is needed for em_ commands. Although it has been working with internal commands for some time (this was done to support parameters), but it would be more correct to use tcm(№), which is done in my code. And, of course, it makes no sense to split the commands into 2 separate launches of the utility. Use my script, where optimization is provided.
Overquoting is evil! 👎
Post Reply