Selecting files with same name or name+ext

Here you can propose new features, make suggestions etc.

Moderators: Hacker, petermad, Stefan2, white

sa16
Senior Member
Senior Member
Posts: 324
Joined: 2021-09-10, 07:15 UTC

Re: Selecting files with same name or name+ext

Post by *sa16 »

I just forgot it.
Thank you for remembering! :)
sa16
Senior Member
Senior Member
Posts: 324
Joined: 2021-09-10, 07:15 UTC

Re: Selecting files with same name or name+ext

Post by *sa16 »

Fla$her wrote: 2025-03-19, 21:50 UTC This is not suitable for names with multiple dots. It should be done by analogy with the following example for the current item:
A dot in regular expressions is a meta-character and is used to search for an arbitrary character,
as a result, an error occurs, the command for the cursor on name1.1.txt mark name1_1.txt, name1x1.txt, etc.
There are also problems with other (^() [] {} $ + ) meta-characters in names...
User avatar
petermad
Power Member
Power Member
Posts: 16021
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Selecting files with same name or name+ext

Post by *petermad »

sa16 wrote: 2025-03-25, 12:58 UTC A dot in regular expressions is a meta-character and is used to search for an arbitrary character,
that is why the dot is escaped with a \ in Fla$her's regexp: <^%O\.?[^.]*$
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Fla$her
Power Member
Power Member
Posts: 2996
Joined: 2020-01-18, 04:03 UTC

Re: Selecting files with same name or name+ext

Post by *Fla$her »

sa16 wrote: 2025-03-25, 12:58 UTCas a result, an error occurs
Yes, it's necessary to escape metacharacters inside %O, which I usually do in scripts at the expense of another regexp. You can't do this in a regular button.
It's possible to use a chain of two em_ commands. The first one will have "sed ...|clip", and the second one will have my button analog, but instead of %O it will be %|CLIPNAME1|. But given my code for Autorun, I guess this idea doesn't make much sense anymore.
Overquoting is evil! 👎
sa16
Senior Member
Senior Member
Posts: 324
Joined: 2021-09-10, 07:15 UTC

Re: Selecting files with same name or name+ext

Post by *sa16 »

2petermad
This is the dot before the extension, and other dots may be in the most base name (%O): "name1.1".
User avatar
petermad
Power Member
Power Member
Posts: 16021
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Selecting files with same name or name+ext

Post by *petermad »

and other dots may be in the most base name (%O):
You are right name1.name2.ext will erroneously match for example name1,name2.ext
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
sa16
Senior Member
Senior Member
Posts: 324
Joined: 2021-09-10, 07:15 UTC

Re: Selecting files with same name or name+ext

Post by *sa16 »

petermad wrote: 2025-03-20, 13:21 UTC 2sa16
The more characters you allow in the extension, the bigger risk of false markings.
This option, in my opinion, is better:

Code: Select all

TOTALCMD#BAR#DATA
SELECTFILESS
"%S:~-0,255.*." "%S:~-0,255"
wcmicons.dll,39
Select all items with same base name as selected items|Hold Shift to also select folders
But the problem with DEFAULT.BAR.bak --> DEFAULT.BAR remains.
User avatar
petermad
Power Member
Power Member
Posts: 16021
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Selecting files with same name or name+ext

Post by *petermad »

2sa16

Much better :-)
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
sniper0
Junior Member
Junior Member
Posts: 4
Joined: 2025-03-19, 01:31 UTC

Re: Selecting files with same name or name+ext

Post by *sniper0 »

petermad wrote: 2025-03-20, 03:16 UTC 2sniper0
Hmm, If i mark/select for example the first 5 files in any of the panels, and then use the second button here above - then the corresponding files are selected in the opposite panel.

You have to mark the files to indicate which ones you want a match for - if you only click the button, only the file under the cursor will be matched.
Marked the first 5 file and the buttons dont work, no matches found. Changed to other panel but no luck.
sa16
Senior Member
Senior Member
Posts: 324
Joined: 2021-09-10, 07:15 UTC

Re: Selecting files with same name or name+ext

Post by *sa16 »

2sniper0
What version of the program do you have? Need TC 10.00 and fresher.
sniper0
Junior Member
Junior Member
Posts: 4
Joined: 2025-03-19, 01:31 UTC

Re: Selecting files with same name or name+ext

Post by *sniper0 »

sa16 wrote: 2025-03-30, 15:39 UTC 2sniper0
What version of the program do you have? Need TC 10.00 and fresher.
9.0a :/
sa16
Senior Member
Senior Member
Posts: 324
Joined: 2021-09-10, 07:15 UTC

Re: Selecting files with same name or name+ext

Post by *sa16 »

sa16 wrote: 2025-03-27, 07:12 UTC But the problem with DEFAULT.BAR.bak --> DEFAULT.BAR remains.
As if the problem is solved by a chain of em_commands:

Code: Select all

[em_SelS_1]
cmd=SELECTFILESS
param=""%S:~-0,255.*.""
[em_SelS_2]
cmd=SELECTFILESS
param=""%S:~-0,255" | "*.*.*""
or, likewise, with the TCFS2 button:

Code: Select all

TOTALCMD#BAR#DATA
%COMMANDER_PATH%\Utils\TCFS2\TCFS2.exe /ef
"set_ini(`%%COMMANDER_PATH%%\usercmd.ini`,em_TempParam,cmd,`SELECTFILESS`) set_ini(`%%COMMANDER_PATH%%\usercmd.ini`,em_TempParam,param,`""%%S:~-0,255.*.""`) tem(`em_TempParam`) delay(100) if(findwnd(`#32770`), send(`{ENTER}`, findwnd(`#32770`))) set_ini(`%%COMMANDER_PATH%%\usercmd.ini`,em_TempParam,cmd,`SELECTFILESS`) set_ini(`%%COMMANDER_PATH%%\usercmd.ini`,em_TempParam,param,`""%%S:~-0,255" | "*.*.*""`) tem(`em_TempParam`) delay(100) if(findwnd(`#32770`), send(`{ENTER}`, findwnd(`#32770`)))"
wcmicons.dll,39
Select all items with same base name as selected items|Hold Shift to also select folders
User avatar
petermad
Power Member
Power Member
Posts: 16021
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Re: Selecting files with same name or name+ext

Post by *petermad »

sa16 wrote: 2025-04-10, 05:45 UTC As if the problem is solved by a chain of em_commands:

Code: Select all

[em_SelS_1]
cmd=SELECTFILESS
param=""%S:~-0,255.*.""
[em_SelS_2]
cmd=SELECTFILESS
param=""%S:~-0,255" | "*.*.*""
That solution selects the correct files if i place the cursor on DEFAULT.BAR.bak but gives me the message: "No matches found!"


This solution:

Code: Select all

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


-1
seems to work universally, but can not select files with the same name but NO extension.
License #524 (1994)
Danish Total Commander Translator
TC 11.51 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1391a
TC 3.60b4 on Android 6, 13, 14
TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
sa16
Senior Member
Senior Member
Posts: 324
Joined: 2021-09-10, 07:15 UTC

Re: Selecting files with same name or name+ext

Post by *sa16 »

petermad wrote:That solution give selects the correct files if i place the cursor on DEFAULT.BAR.bak but gives me the message: "No matches found!"
It is better to have the correct result with an error message than the wrong one without a message.
This is due to the need to use two commands SELECTFILES. In the TCFS2 button, I automatically suppress this message.

It would be convenient to add the suffix 0 in the SELECTFILES command to suppress error messages (similar to LOADLIST and LOADLIST0).
When select files from the buffer (cm_LoadSelectionFromClip) or file (LOADSELECTION), TC does not report errors at all.
Post Reply