Button to select first folder starting with a certain letter?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Dazzer
Junior Member
Junior Member
Posts: 67
Joined: 2016-12-14, 08:35 UTC
Location: Amsterdam

Button to select first folder starting with a certain letter?

Post by *Dazzer »

Hi folks,

Please take a look at the image below.

Image: https://ibb.co/ZS2ptsk

I have created a second button bar of the alphabet (i made these ICOs, if you want them, grab them here:
https://drive.google.com/file/d/1Tzk_h257HFmlTIj2FdQgPqkSk8smuECB/view?usp=sharing)

When i click on, for example, button P, i want to select the first folder on the drive (or inside another folder) that starts with the letter P.
But i don't want to go inside the folder, i just want it selected and visible in the viewer.

Is that somehow possible?

Thanks!
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 »

Code: Select all

selectfilesD <^p
A button with the above command will select all the [visible] folders with names starting with the p letter in the active pane.
To select exclusively the first one of such folders, and, moreover, to do it in a recursive mode, seemes to be a pretty challenging task.
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10
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 »

Thanks!

Could a workaround would be if i just created one dummy folder for each alphabet letter, so in my example: :\P\

Then pressing the "P" button would select (and show in the window) that folder selected without going inside it.

Might that be do-able?
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 »

Configuration > Quick Search > ◉ Letter only + ☑ Beginning (name must start with first typed character)
cm_GoToFirstEntry,cm_QuickSearch
Overquoting is evil! 👎
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 »

That works, but requires two extra steps (type letter, enter).

Or maybe i misunderstand?
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 »

Ok, so i got it working with a dummy folder.

Folder name: P00

Command: selectfilesD <^P00

That's good enough for me, but if anyone knows how to do it without the dummy folders, I'd be happy to hear it!

EDIT: one detail, with the above workaround, the P00 folder is selected and in view, but at the bottom of the window.

But because the whole point of this is to be able to quickly browse all P folders, it would make more sense if it was highlighted and placed near the top of the window.

Do we have any control over where the selected item is, window-wise?
Last edited by Dazzer on 2023-12-12, 00:22 UTC, edited 2 times in total.
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-12, 00:10 UTCThat works, but requires two extra steps (type letter, enter).
The setting doesn't require this. Press Home, then enter the letter.
I've given the chain of command as an alternative.
Overquoting is evil! 👎
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 »

Fla$her wrote: 2023-12-12, 00:19 UTC
Dazzer wrote: 2023-12-12, 00:10 UTCThat works, but requires two extra steps (type letter, enter).
The setting doesn't require this. Press Home, then enter the letter.
I've given the chain of command as an alternative.
OK! but still one extra action, compared to just pressing the P button i created!
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 »

Which one?
Overquoting is evil! 👎
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 »

Sorry, maybe i misunderstand, but you said press "Press Home, then enter the letter".

That's two actions.

Pressing the P button in my above workaround is one action.
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 »

You just marking files that start with the specified letters. But you don't select the first file as you requested at the beginning.
A quick search takes you to the first file, but only from the beginning of the list, so you need to press Home.
Of course, you can select a file using the hotkey assigned to em_p:
%COMMANDER_PATH%\Addons\TCFS2\TCFS2.exe /ef sendmsg(msg(1074,3),$0B,0) tcm(2049) tcm(2056) send(@p) tcm(2918) sendmsg(msg(1074,3),$0B,1)

But I definitely wouldn't replace the letter keys themselves with such a command. But that's probably what you need.
Last edited by Fla$her on 2023-12-12, 08:17 UTC, edited 1 time in total.
Overquoting is evil! 👎
User avatar
petermad
Power Member
Power Member
Posts: 14808
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

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

Post by *petermad »

But i don't want to go inside the folder, i just want it selected and visible in the viewer.
Are you talking about selecting the folder in the Separate Tree or in the File Panel? And what do you mean by "the viewer"?

Anyway, in both the Tree and the File Panel you can use Quick Search to go to an item that starts with a certain letter .- just press Ctrl+Alt+Letter to jump to the folder that starts with that letter. You configure which keys to use for the Quick Search in "Configuration" -> "Options..." -> "Quick Search"

In the file panel in anything but Tree View it is NOT possible to select a subfolder to the shown folders - you can only select visible elements.


The buttons can NOT work for the Separate Tree, but you could make for example the A-button and B-button for selecting folders in the file Panel like this:
In your usercmd.ini (located in the same folder as your wincmd.ini file) you can add this:

Code: Select all

[em_unmarkNextSelected]
cmd=cm_SrcByName 8,cm_SrcByName 1,cm_GoToNextSelected,cm_GoToNext,cm_Unselect 50,cm_GoToPrevSelected,cm_SrcByName 9

[em_selectA]
cmd=SELECTFILESD a*

[em_selectB]
cmd=SELECTFILESD b*
etc.

Put this in the Command Field of your A button:

Code: Select all

em_selectA,em_unmarkNextSelected

Put this in the Command Field of your B button:

Code: Select all

em_selectB,em_unmarkNextSelected
etc.

You would have to make an em_command in your usercmd.ini file for each letter.

You will have to be sure to be at the first entry [..] in the File Panel before you start the first selection, and you would have to click the buttons in alphabetical order if you want to select more than one folder.

It will not work reliably if the Tree is shown in the folder panel.
It will not work if there are more than 50 folders starting with the same letter.

This is not a perfect solution, but the best I can think of without having to use external utilities like AutoHotkey or TCFS2.
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
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 »

This is 9/10 of a TotalCommander button.
The only downside it would launch Explorer. Lol.
Otherwise, it does exactly what is requested.

Code: Select all

Invoke-Expression "explorer '/select,$((Get-ChildItem $pwd -Directory -recurse | Where-Object -Property Name -match '^p' | Select-Object -First 1).FullName)'"
It will find and highlight the first p-folder no matter how deep it's being dug.
#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 »

2petermad
Placing the cursor on a folder is a folder selection. So here instead of em_unmarkNextSelected it's more correct like this:

Code: Select all

[em_GoToFirstSelectedFolder]
cmd=cm_GoToFirstEntry,cm_GoToPrev,cm_GoToNextSelected,cm_GoToPrevSelected,cm_ClearAllFolders
And perform with the preliminary removal of the selection: cm_ClearAllFolders,em_selectA,em_GoToFirstSelectedFolder
Overquoting is evil! 👎
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 »

These versions now work with the Total Commander itself.

This one will search for the P-folder recursively, find the first P-folder wherever it is, and enter it:

Code: Select all

Invoke-Expression "$env:commander_exe /O $((Get-ChildItem $pwd -Directory -recurse | Where-Object -Property Name -match '^p' | Select-Object -First 1).FullName)"
This one will search for the P-folder recursively, find the first P-folder wherever it is, and set the cursor on it, highlighting it:

Code: Select all

Invoke-Expression "$env:commander_exe /O /P /S $((Get-ChildItem $pwd -Directory -recurse | Where-Object -Property Name -match '^p' | Select-Object -First 1).FullName)"
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10
Post Reply