Button to select first folder starting with a certain letter?

English support forum

Moderators: white, Hacker, petermad, Stefan2

User avatar
beb
Senior Member
Senior Member
Posts: 435
Joined: 2009-09-20, 08:03 UTC
Location: Odesa, Ukraine

Re: Button to select first folder starting with a certain letter?

Post by *beb »

Working TC button for testing.

Code: Select all

TOTALCMD#BAR#DATA
em_test_tc_command

WCMICON2.DLL,11


0
10028

Code: Select all

[em_test_tc_command]
cmd=Powershell -ExecutionPolicy Bypass;
param=& $env:commander_exe /O /P /S "$((Get-ChildItem $pwd -Directory -recurse | Where-Object -Property Name -match '^p' | Select-Object -First 1).FullName)"
What it does: searches for the P-folder recursively, finds the first P-folder wherever it is (if any), and sets the cursor on it, highlighting it (in case of a huge folder list it will be scrolled to bring the folder in question in front of the eyes of the beholder).
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10
Fla$her
Power Member
Power Member
Posts: 2318
Joined: 2020-01-18, 04:03 UTC

Re: Button to select first folder starting with a certain letter?

Post by *Fla$her »

2beb
Powershell is the last tool that can be seriously considered for navigation, especially frequent. I hope you understand that? πŸ™„
In addition, as far as I understand, the current sorting should be taken into account here, and not exclusively alphabetical in the forward direction.

"highlighting it" > "selecting it" in this case.
Overquoting is evil! πŸ‘Ž
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Button to select first folder starting with a certain letter?

Post by *petermad »

Fla$her wrote: ↑2023-12-12, 02:11 UTC 2petermad
Placing the cursor on a folder is a folder selection.
I disagree (I would call that highlighting the folder), and without a genuine selection, the user cannot select for example BOTH the first folder starting with an A AND the first folder starting with a B by clicking the A followed by the B button. That is what I wanted to accomplish and why I wrote that the buttons has to be clicked in alphabetical order.

With your suggestion you can only select/highlight one folder, because you do a cm_GoToFirstEntry,cm_GoToPrev every time. a button is clicked and you clear all folder selections with cm_ClearAllFolders .

Also the cm_GoToPrevSelected in
cmd=cm_GoToFirstEntry,cm_GoToPrev,cm_GoToNextSelected,cm_GoToPrevSelected,cm_ClearAllFolders
has no effect, beside giving an error sound, because there is no previous selected folder, when you are on the first selected folder.

Fla$her wrote:And perform with the preliminary removal of the selection: cm_ClearAllFolders,em_selectA,em_GoToFirstSelectedFolder
Again - that defies the ability to select more than one folder.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Button to select first folder starting with a certain letter?

Post by *petermad »

I have improved the em_unmarkNextSelected command (see: viewtopic.php?p=446577#p446577) so that it also works when the initial sorting is NOT by name.

so I changed if from:

Code: Select all

[em_unmarkNextSelected]
cmd=cm_GoToNextSelected,cm_GoToNext,cm_Unselect 50,cm_GoToPrevSelected
to:

Code: Select all

[em_unmarkNextSelected]
cmd=cm_SrcByName 8,cm_SrcByName 1,cm_GoToNextSelected,cm_GoToNext,cm_Unselect 50,cm_GoToPrevSelected,cm_SrcByName 9
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2318
Joined: 2020-01-18, 04:03 UTC

Re: Button to select first folder starting with a certain letter?

Post by *Fla$her »

petermad wrote: ↑2023-12-12, 11:11 UTCI disagree (I would call that highlighting the folder), and without a genuine selection
No, this is a misconception. It's exactly the opposite. >>
Fla$her wrote: ↑2023-05-20, 00:40 UTC highlighting is optional for selection:
ghisler(Author) wrote: ↑2013-06-17, 09:04 UTCThe file under the cursor is treated as selected when nothing else is selected.
Selection, roughly speaking, is equal to choice, Π°nd the highlight is equivalent to a mark.

petermad wrote: ↑2023-12-12, 11:11 UTC the user cannot select for example BOTH the first folder starting with an A AND the first folder starting with a B by clicking the A followed by the B button.
I didn't understand why he needed to press A when going to the folder with B?
petermad wrote: ↑2023-12-12, 11:11 UTC That is what I wanted to accomplish and why I wrote that the buttons has to be clicked in alphabetical order.
What do you mean by buttons? Isn't it about binding to the keys?
I just didn't download the library, so I didn't see what was there. Buttons with letters?
petermad wrote: ↑2023-12-12, 11:11 UTCWith your suggestion you can only select/highlight one folder, because you do a cm_GoToFirstEntry,cm_GoToPrev every time. a button is clicked and you clear all folder selections with cm_ClearAllFolders .
Again - that defies the ability to select more than one folder.
Absolutely right. Selecting the first (i.e. one) folder is the essence of the request, right in the header and beyond.
There was no conversation about selecting multiple folders.
petermad wrote: ↑2023-12-12, 11:11 UTC Also the cm_GoToPrevSelected in has no effect, beside giving an error sound, because there is no previous selected folder, when you are on the first selected folder.
πŸ˜€ Wrong. Since I have been in the subject of navigation codes for quite a long time, I know exactly why this is necessary.
I wouldn't put anything in just like that. This is necessary when setting ShowParentDirInRoot=0 for the drive root.
Overquoting is evil! πŸ‘Ž
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Button to select first folder starting with a certain letter?

Post by *petermad »

Fla$her wrote: ↑2023-12-12, 14:03 UTC
petermad wrote: ↑2023-12-12, 11:11 UTC the user cannot select for example BOTH the first folder starting with an A AND the first folder starting with a B by clicking the A followed by the B button.
I didn't understand why he needed to press A when going to the folder with B?
He did not indicate whether he wanted to be able to select more than one folder by first letter - I am providing the choice of selecting several.
Fla$her wrote: ↑2023-12-12, 14:03 UTC
petermad wrote: ↑2023-12-12, 11:11 UTC That is what I wanted to accomplish and why I wrote that the buttons has to be clicked in alphabetical order.
What do you mean by buttons? Isn't it about binding to the keys?
I just didn't download the library, so I didn't see what was there. Buttons with letters?
Yes - buttons with letters! and the title of this topic is "Button to select first folder starting with a certain letter"
Fla$her wrote: ↑2023-12-12, 14:03 UTC There was no conversation about selecting multiple folders.
There wasn't any conversation about NOT selecting multiple folders either.
Fla$her wrote: ↑2023-12-12, 14:03 UTC
petermad wrote: ↑2023-12-12, 11:11 UTC Also the cm_GoToPrevSelected in has no effect, beside giving an error sound, because there is no previous selected folder, when you are on the first selected folder.
πŸ˜€ Wrong. Since I have been in the subject of navigation codes for quite a long time, I know exactly why this is necessary.
I wouldn't put anything in just like that. This is necessary when setting ShowParentDirInRoot=0 for the drive root.
You are right, I didn't consider the root. Just annoying with that error ding when the command is used in folders.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2318
Joined: 2020-01-18, 04:03 UTC

Re: Button to select first folder starting with a certain letter?

Post by *Fla$her »

petermad wrote: ↑2023-12-12, 14:53 UTC He did not indicate whether he wanted to be able to select more than one folder by first letter - I am providing the choice of selecting several.
Are you talking about the em_select[A|B|etc] commands? But this doesn't contradict my proposal in any way. I didn't touch these commands, only marking the letter A in green to indicate the variability:
Fla$her wrote: ↑2023-12-12, 02:11 UTC cm_ClearAllFolders,em_selectA,em_GoToFirstSelectedFolder

petermad wrote: ↑2023-12-12, 14:53 UTC Yes - buttons with letters! and the title of this topic is "Button to select first folder starting with a certain letter"
Understood. It's just that some people refer to the keys as buttons, so I didn't pay attention to it because of the reference to the letter.
petermad wrote: ↑2023-12-12, 11:11 UTC That is what I wanted to accomplish and why I wrote that the buttons has to be clicked in alphabetical order.
If I execute cm_ClearAllFolders,em_selectB,em_GoToFirstSelectedFolder after cm_ClearAllFolders,em_selectA,em_GoToFirstSelectedFolder, then there will be no problems. Or did you write about something else?
petermad wrote: ↑2023-12-12, 14:53 UTC There wasn't any conversation about NOT selecting multiple folders either.
First β€” one. No?
petermad wrote: ↑2023-12-12, 14:53 UTC Just annoying with that error ding when the command is used in folders.
My sounds are turned off, so I wouldn't have noticed it without your prompting. On TCFS2, this can be fixed like this:
TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Addons\TCFS2\TCFS2.exe /ef sendmsg(msg(1074,3),$0B,0) tcm(3305) tem(em_selectA) tcm(2049) tcm(2056) tcm(2053) if(!msg(1074,1008+msg(1074,1000)),tcm(2054)) tcm(3305) tcm(2918) sendmsg(msg(1074,3),$0B,1)

wciconex.dll,222
Jump to folder name starting with A
Overquoting is evil! πŸ‘Ž
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Button to select first folder starting with a certain letter?

Post by *petermad »

I have now come up with a more robust approach:

usercmd.ini:

Code: Select all

[em_selectItem0]
cmd=SELECTFILESD
param=%N

[em_selectItem]
cmd=cm_GoToFirstEntry,cd "*",cm_RestoreSelection,em_selectItem0

[em_selectA]
cmd=cd a*\

[em_selectB]
cmd=cd b*\
etc.

Button commands:

Code: Select all

cm_SaveSelection,em_selectA,em_selectItem

cm_SaveSelection,em_selectB,em_selectItem
etc.

These command also work even if the cursor is not at the top before start. Multiple folders with different start letter can be marked, and the sequence of which the letter buttons are clicked is of no importance. You will get an error message if no folder starts with the selected letter. No error sounds for every selection. Only backside is that if there is no matching folder, the cursor will be placed on the first file if any.


If the goal is only to place the cursor over the matching folder, without marking the folder this approach can be used:

Code: Select all

[em_selectItem]
cmd=cm_GoToFirstEntry,cd "*"

[em_selectA]
cmd=cd a*\|*

[em_selectB]
cmd=cd b*\|*
etc.

Button commands:

Code: Select all

em_selectA,em_selectItem

em_selectB,em_selectItem
etc.

With this approach the cursor is placed at the first item (i.e [..] in directories, and at the first folder in the root) if there is no matching folder.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Dazzer
Junior Member
Junior Member
Posts: 67
Joined: 2016-12-14, 08:35 UTC
Location: Amsterdam

Re: Button to select first folder starting with a certain letter?

Post by *Dazzer »

Hi guys,

You're going deep!

I kinda abandoned my original idea and am just using the home + search function.

Quick question: is there a hotkey that will take you to a certain location in a certain file panel?

So, for example, i'm in the right file panel in c:\workspace

And i want a hotkey that'll bring up v:\workspace\audio

And is there a way to have a hotkey like home + search that will search in a specific folder, even if you're not in the folder (in the file panel)?
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Button to select first folder starting with a certain letter?

Post by *petermad »

Quick question: is there a hotkey that will take you to a certain location in a certain file panel?
So, for example, i'm in the right file panel in c:\workspace
And i want a hotkey that'll bring up v:\workspace\audio ?
Ther is no such hotkey, but you can make them.

You make the command for the hotkey by running: cm_CommandBrowser from TC's command line and then click un usercmd.ini in the bottom of the left panel of that dialog.

You can assign a hotkey (called keyboard remapping) to the command you made by running cm_Confirmation from TC's command line.

the command you need to to make for going to v:\workspace\audio is : cd v:\workspace\audio

If you don't have TC's command line visible near the bottom of the TC window, you can open it temporarily by pressing the Right-arrow key on your keyboard.

And is there a way to have a hotkey like home + search that will search in a specific folder, even if you're not in the folder (in the file panel)
You cannot search for a file name this way, if you are not in the folder you want to search in. You can use TC's "Find Files" (Alt+F7) for that.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2318
Joined: 2020-01-18, 04:03 UTC

Re: Button to select first folder starting with a certain letter?

Post by *Fla$her »

Dazzer wrote: ↑2023-12-14, 08:00 UTC I kinda abandoned my original idea and am just using the home + search function.
The expected choice. I wouldn't bother with buttons either.
Dazzer wrote: ↑2023-12-14, 08:00 UTC Quick question: is there a hotkey that will take you to a certain location in a certain file panel?
These are the basics and an obvious offtop. The question is not quick if you go into details with the speed of navigating to the folder (cd/TCFS2/TCMC vs %COMMANDER_EXE% /O), activating the target panel, creating a tab and placing the cursor on the folder (%COMMANDER_EXE% /O /P).
Dazzer wrote: ↑2023-12-14, 08:00 UTC And is there a way to have a hotkey like home + search that will search in a specific folder, even if you're not in the folder (in the file panel)?
There are no such technologies in TC. If you need to search for a file in the depth of the working folder, then before using the quick search, you can press Ctrl+B to display all the files in the folder structure. Otherwise, it makes sense to use Everything, which will instantly find what you need in the generated database. But it will be more like a quick filter.

petermad wrote: ↑2023-12-14, 09:16 UTC by pressing the Right-arrow key
Shift+Left/Right actually.
Overquoting is evil! πŸ‘Ž
User avatar
petermad
Power Member
Power Member
Posts: 14809
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Button to select first folder starting with a certain letter?

Post by *petermad »

Shift+Left/Right actually.
Sure - Shift is necessary only in Brief mode though.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2318
Joined: 2020-01-18, 04:03 UTC

Re: Button to select first folder starting with a certain letter?

Post by *Fla$her »

Shift is necessary only in Brief mode though.
In the case of SpecialCursorMovement > 0 and β‰  4 β€” in any mode.
Overquoting is evil! πŸ‘Ž
Post Reply