How to quickly select files having same basenames?

English support forum

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
linkun
Junior Member
Junior Member
Posts: 15
Joined: 2021-01-09, 05:40 UTC

How to quickly select files having same basenames?

Post by *linkun »

I have a folder containing the following files:

Code: Select all

a.doc
a.docx
a.pdf
a.xlsx
b.dwg
b.pdf
c.ppt
c.pdf
I have select a.docx and b.dwg.
How to quickly select all the files which have the same basenames as that of the selected files in current folder?
Basename has the same meaning as it in Powershell. It means filename without extension name. For instance: the basename of a file named "test.docx" is "test".
#359839
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: How to quickly select files having same basenames?

Post by *ghisler(Author) »

Place the cursor on one of them, then use internal command cm_SelectCurrentName, e.g. via a button or user-defined hotkey, or the command line at the bottom.
Author of Total Commander
https://www.ghisler.com
User avatar
linkun
Junior Member
Junior Member
Posts: 15
Joined: 2021-01-09, 05:40 UTC

Re: How to quickly select files having same basenames?

Post by *linkun »

ghisler(Author) wrote: 2021-09-26, 07:16 UTC Place the cursor on one of them, then use internal command cm_SelectCurrentName, e.g. via a button or user-defined hotkey, or the command line at the bottom.
Not quickly enough. Is it able to select files having the same basenames more quickly as select files having the same extension names?
#359839
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: How to quickly select files having same basenames?

Post by *Hacker »

linkun,
Not quickly enough.
:?:

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: How to quickly select files having same basenames?

Post by *petermad »

2linkun
Not quickly enough. Is it able to select files having the same basenames more quickly as select files having the same extension names?
Its is just as quick as the cm_SelectCurrentExtension command (Alt+Num +).

Are you aware that you can asign the cm_SelectCurrentName to a keyboard shortcut (for example Alt+Shift+Num +) or a button in the button bar.
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
linkun
Junior Member
Junior Member
Posts: 15
Joined: 2021-01-09, 05:40 UTC

Re: How to quickly select files having same basenames?

Post by *linkun »

ghisler(Author) wrote: 2021-09-26, 07:16 UTC Place the cursor on one of them, then use internal command cm_SelectCurrentName, e.g. via a button or user-defined hotkey, or the command line at the bottom.
Many many thanks.
But It's a little different from What I want.
When I select 2 files having different basenames, such as "a.xlsx b.dwg", I want TC can select all files that have a basename of "a" or "b" in current folder.
#359839
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: How to quickly select files having same basenames?

Post by *Hacker »

linkun,
You will need to first select the "a" files and then the "b" files. I don't think there is a way to select both "a" and "b" files at the same time.

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: How to quickly select files having same basenames?

Post by *nsp »

The current command only select file under the cursor and extend selection but it is not possible to call it multiple time to increase selection for more than one file at the time !

I like clipboard management as it does not need dedicated file name for intermediate parsing.


What you can do, is to use a script to automate : (Powerpro autoHotKey AutoIt ... powershell )

call TC cm_copyNamesToClip
- read clipboard and for each line remove .<extension> and add .* at the end, remove prefix path if working in BranchView
- fill clipboard with new list
-- <ensure clipboard is filled before calling next TC cmd> --
call TC cm_LoadSelectionFromClip

Manually you can call the TC Commands and use an editor with regexp replacement as intermediate clipboard manipulation to better understand the process..

You can also separate clipboard manipulation into a user command and call all with a small wait in a multi command...


-- Edited erratum for BranchView prefix folder is not added to name
powersell snippet to replace all .xxxxx with .* in clipboard

Code: Select all

Set-Clipboard ( (get-clipboard) -replace '^(.+)(\.[^.]+)$','$1.*')
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: How to quickly select files having same basenames?

Post by *petermad »

2linkun

This button can select files with same base names as the selected files:

Code: Select all

TOTALCMD#BAR#DATA
SELECTFILES
"%S:~-0,255.*"
wcmicons.dll,39
Select all files with same base names as selected files


-1
1
To make the button:
1. Mark the text in the box here above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctrl+C).
3. Right click on TC's buttonbar and choose "Paste".

Note:
The SELECTFILES command supports lists up to 32767 characters
You need TC 10.0 for this button to work
Last edited by petermad on 2021-10-05, 01:57 UTC, edited 2 times in total.
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: How to quickly select files having same basenames?

Post by *petermad »

Improved version of the button:

Code: Select all

TOTALCMD#BAR#DATA
SELECTFILESS
"%S:~-0,255.*"
wcmicons.dll,39
Select all items with same base names as selected items - hold Shift down to also select folders


-1
Folders can be included by holding down shift while clicking the button.

Note: it does not work when selecting files / folders without an extension.
Last edited by petermad on 2021-10-05, 01:56 UTC, edited 2 times in total.
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
User avatar
nsp
Power Member
Power Member
Posts: 1803
Joined: 2005-12-04, 08:39 UTC
Location: Lyon (FRANCE)
Contact:

Re: How to quickly select files having same basenames?

Post by *nsp »

@PeterMad
The solution you gave works fine in single folder but fail in BranchView as in %S the path (from base folder) is prefixed and the :~-0,nnn syntax keep it part of the name.

255 chars could also be short fo some filename but works for 99.99% of the time ;)

@ghisler It is really great to have ":~-0 with this special meaning but just found it in history and not in help as no substring section have been made in the index.
User avatar
petermad
Power Member
Power Member
Posts: 14739
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: How to quickly select files having same basenames?

Post by *petermad »

2nsp
The solution you gave works fine in single folder but fail in BranchView as in %S the path (from base folder) is prefixed and the :~-0,nnn syntax keep it part of the name.
Yes, that is a limitation of the SELECTFILES command - it only works with filenames without path.

...just found it in history and not in help as no substring section have been made in the index
It is in the help for Configuration - Change Button bar:
Help wrote:Parameters:
Here you can specify command line parameters. Fixed parameters must be specified directly after the file name, because otherwise, in a Drag&Drop, only the file name would be given to the program.
Note: All parameters now support substring fields in the form :~start,length, e.g. %N:~2,5 or %N:~-8,5 . To append a number directly after the length value, use another ~ character, e.g. %N:~2,5~2. Negative vaules are measured from the end of the string. Example: %P:~0,-1 cuts off the backslash from the path.
The Start value -0 is special: %N:~-0,20 copies the first 20 characters of the name without extension, %N:~-0,-20 the first 20 characters of the extension without the name.

255 chars could also be short fo some filename but works for 99.99% of the time
Remember it is only file name, not full path - so I think 255 will suffice in 99.99% of the cases as you write.

I made a bug/missing feature rapport about the ~-0 parameter substring, that it returns an empty string if there is no file extension: https://www.ghisler.ch/board/viewtopic.php?p=405873
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.50b4 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Post Reply