Mark files based on the last characters of a certain selcted file
Moderators: white, Hacker, petermad, Stefan2
Mark files based on the last characters of a certain selcted file
Hi,
Is there a way to select only some files in one folder based on the last 5 characters of that file's name, using a hotkey mapped with a certain command?
Let's say I have a folder with 100 files.
They have different names, but I want to select only the 10 that have the same 5 letters/numbers+extension at the back.
So when I would use something like a "Ctrl + /", the program could check the last characters of the selected file and mark all files with those last characters.
It's a combination of the commands "cm_SelectCurrentExtension" (Select all files with same extension) and "cm_SelectCurrentNameExt".
I know I could do this by using "Ctrl + s" and then searching the extension that I need, but what I need would help me gain more time.
Thank you
Is there a way to select only some files in one folder based on the last 5 characters of that file's name, using a hotkey mapped with a certain command?
Let's say I have a folder with 100 files.
They have different names, but I want to select only the 10 that have the same 5 letters/numbers+extension at the back.
So when I would use something like a "Ctrl + /", the program could check the last characters of the selected file and mark all files with those last characters.
It's a combination of the commands "cm_SelectCurrentExtension" (Select all files with same extension) and "cm_SelectCurrentNameExt".
I know I could do this by using "Ctrl + s" and then searching the extension that I need, but what I need would help me gain more time.
Thank you
Re: Mark files based on the last characters of a certain selcted file
Is the 5 letters and the extension always the same?
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
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
Re: Mark files based on the last characters of a certain selcted file
Examples of file names are always useful if somebody ask for help.
Re: Mark files based on the last characters of a certain selcted file
Let me simplify.
Let's say I have 6 files in a folder:
12345aaaaa.txt
12345bbbbb.txt
12345ccccc.txt
12345ddddd.txt
12345aaaaa.jpg
54321aaaaa.txt
When I open the folder and select the first file, with a certain command the program would mark the first and the last files in this example, because they both have the same ending (aaaaa) and they both are the same type of files (txt).
Thank you.
Let's say I have 6 files in a folder:
12345aaaaa.txt
12345bbbbb.txt
12345ccccc.txt
12345ddddd.txt
12345aaaaa.jpg
54321aaaaa.txt
When I open the folder and select the first file, with a certain command the program would mark the first and the last files in this example, because they both have the same ending (aaaaa) and they both are the same type of files (txt).
Thank you.
Re: Mark files based on the last characters of a certain selcted file
So you want basically select all files with same last 9 signs as first first selected file.
Me think that need a external AutoHotkey script:
- CurrName = get current name
- Last = get last 9 signs from CurrName
- FileList = get all files in folder
- loop FileList ; if last-9-signs = Last then store name to outList
- select all files from outList
If I find some time I will try this out....
Me think that need a external AutoHotkey script:
- CurrName = get current name
- Last = get last 9 signs from CurrName
- FileList = get all files in folder
- loop FileList ; if last-9-signs = Last then store name to outList
- select all files from outList
If I find some time I will try this out....
Re: Mark files based on the last characters of a certain selcted file
One possibility might be to use "Everything" to filter out the desired files.
- In TC, call up the desired folder, then place the cursor on [..].
- Press Button with command: %COMMANDER_PATH%\Tools\Everything-portabel\Everything.exe -parent, parameter: %V *)
"Everything" is called with the current path from TC
- Enter the desired text directly in "Everything", e.g. aaaaa.txt after the path and a space ... the result is displayed immediately.
- Optional: CTRL+S ... Export result list (.csv, .txt, ...)
*) Path to Everything.exe must be adjusted.
https://www.ghisler.ch/wiki/index.php?title=Navigation - Pseudo environment variables
%COMMANDER_PATH% ... is where TOTALCMD.EXE and TOTALCMD64.EXE is located
(cd %COMMANDER_PATH% <enter> in TC command line ...).
In "Everything" there is the possibility to save filters, bookmarks and keyboard shortcuts.
A search history is also available.
For me, however, the question remains what should happen to the marked files afterwards.
Should they be copied or moved or should only a quick view be carried out?
In "Everything" you can also preview certain file types (menu "View" - "Preview").
and a shortcut, e.g. CTRL+Q can be defined.
- In TC, call up the desired folder, then place the cursor on [..].
- Press Button with command: %COMMANDER_PATH%\Tools\Everything-portabel\Everything.exe -parent, parameter: %V *)
"Everything" is called with the current path from TC
- Enter the desired text directly in "Everything", e.g. aaaaa.txt after the path and a space ... the result is displayed immediately.
- Optional: CTRL+S ... Export result list (.csv, .txt, ...)
*) Path to Everything.exe must be adjusted.
https://www.ghisler.ch/wiki/index.php?title=Navigation - Pseudo environment variables
%COMMANDER_PATH% ... is where TOTALCMD.EXE and TOTALCMD64.EXE is located
(cd %COMMANDER_PATH% <enter> in TC command line ...).
In "Everything" there is the possibility to save filters, bookmarks and keyboard shortcuts.
A search history is also available.
For me, however, the question remains what should happen to the marked files afterwards.
Should they be copied or moved or should only a quick view be carried out?
In "Everything" you can also preview certain file types (menu "View" - "Preview").
and a shortcut, e.g. CTRL+Q can be defined.
Re: Mark files based on the last characters of a certain selcted file
At this moment I am interested in quickly mark the files with the same ending so I can rename them.For me, however, the question remains what should happen to the marked files afterwards.
Re: Mark files based on the last characters of a certain selcted file
Then you would have a real-time solution if you used "Everything" with TC.
If you are interested, you can have a look at this short summary here.
Note:
A multiple renaming as in TC does not seem to exist in "Everything".
Re: Mark files based on the last characters of a certain selcted file
There is a multi-rename in Everything.tuska wrote: ↑2018-10-18, 14:07 UTCThen you would have a real-time solution if you used "Everything" with TC.
If you are interested, you can have a look at this short summary here.
Note:
A multiple renaming as in TC does not seem to exist in "Everything".
Mark some files and then use File / Rename
You get a form to specify the rules and conditions with some nice features.
Windows 11 Home x64 Version 23H2 (OS Build 22631.3527)
TC 11.03 x64 / x86
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.77
QAP 11.6.3.3 x64
TC 11.03 x64 / x86
Everything 1.5.0.1373a (x64), Everything Toolbar 1.3.3, Listary Pro 6.3.0.77
QAP 11.6.3.3 x64
Re: Mark files based on the last characters of a certain selcted file
Ahh, thank you!
I haven't noticed that yet, probably because there's no menu item of its own in "Everything",
as e.g. with menu "Edit" - "Advanced" - "Advanced Copy to Folder..." or "Advanced Move to Folder..."
Re: Mark files based on the last characters of a certain selcted file
2Calafalas
Here is a solution that dosn't involve using 'Everything'
Make these 3 commands in your usercmd.ini file:
And put this line in the [Shortcuts] section of your wincmd.ini file to use Ctrl+/ for the command
0r use this button:
Here is a solution that dosn't involve using 'Everything'
Make these 3 commands in your usercmd.ini file:
Code: Select all
[em_findfilepart]
cmd=%COMSPEC% /V /C
param=set filepart=%O && setx filepart !filepart:~-6!
iconic=1
[em_markfiles0]
cmd=SELECTFILES *%filepart%.*
[em_markfiles1]
cmd=em_findfilepart,cm_wait 500,em_markfiles0
Code: Select all
[Shortcuts]
C+/=em_markfiles1
0r use this button:
Code: Select all
TOTALCMD#BAR#DATA
em_findfilepart,cm_wait 500,em_markfiles0
wcmicons.dll,39
Mark files with the same last 5 characters in the name as file under cursor
-1
To make the button:
1. Mark the green text above (click SELECT ALL).
2. Copy it to the ClipBoard (press Ctri+C).
3. Right click on TC's buttonbar and choose "Paste".
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
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
Re: Mark files based on the last characters of a certain selcted file
Wonderful solution, petermad. Works perfect. Good work!
But me think he wants:
param=set filepart=%N && setx filepart !filepart:~-10!
Explanation
Last 5 signs of file base name %O:
param=set filepart=%O && setx filepart !filepart:~-6!
Last 5 signs of file name %N plus including dot and 3 signs extension:
param=set filepart=%N && setx filepart !filepart:~-10!
But me think he wants:
param=set filepart=%N && setx filepart !filepart:~-10!
Explanation
Last 5 signs of file base name %O:
param=set filepart=%O && setx filepart !filepart:~-6!
Last 5 signs of file name %N plus including dot and 3 signs extension:
param=set filepart=%N && setx filepart !filepart:~-10!
Re: Mark files based on the last characters of a certain selcted file
@petermad
Thank you.
This is exactly what I needed. All inside, without using extra tools.
I have 2 extra questions, if you could answer:
1. what does the '500' stands for in the part 'cm_wait 500'? is it the waiting time for the selection to do it's job? can I lower it?
2. one thing that I noticed using this with some xml files:
I have this files:
aaaa01001201.xml
aaaa01001201.doc.xml
bbbb01001201.xml
bbbb01001201.doc.xml
When the selection is over a 'doc.xml' file the marking is done for the 2 'doc.xml' files, as it should.
But when the selection is on the first file "aaaa01001201.xml", the marking is aplying to all the 4 files.
Is it because it sees the 'doc.xml' as an extension?
Can I make it to mark only the first and 3rd in this example?
Thank you all again.
Thank you.
This is exactly what I needed. All inside, without using extra tools.
I have 2 extra questions, if you could answer:
1. what does the '500' stands for in the part 'cm_wait 500'? is it the waiting time for the selection to do it's job? can I lower it?
2. one thing that I noticed using this with some xml files:
I have this files:
aaaa01001201.xml
aaaa01001201.doc.xml
bbbb01001201.xml
bbbb01001201.doc.xml
When the selection is over a 'doc.xml' file the marking is done for the 2 'doc.xml' files, as it should.
But when the selection is on the first file "aaaa01001201.xml", the marking is aplying to all the 4 files.
Is it because it sees the 'doc.xml' as an extension?
Can I make it to mark only the first and 3rd in this example?
Thank you all again.
Re: Mark files based on the last characters of a certain selcted file
2Calafalas
If you always only use it on files with a 3 character extension (3 characters after the last dot), you can change it to:
Or even better use Stefan2's solution, which will also rule out files with different extensions:
But notice that both of these changes will only work with 3-character file extensions
It is a delay of 500 milliseconds - to give Windows enough time to set the global variable (or give TC time to recognize it). I have tried with values of 1, 10, 100m 200 and 500. sometimes 100 works, but on my system only 200 works reliably, so I have set it to 500 to also work on slower systems - you can try lower values. If the value is too low you will get the last used selection in stead of the current - so if you test lower values, you have to test on a different pattern each time, otherwise the test will alway come out correct after the second try.1. what does the '500' stands for in the part 'cm_wait 500'? is it the waiting time for the selection to do it's job? can I lower it?
What you see is a limitalion of TC's SELECTFILES command. It handles *xx.* and *xx* the same way, but so does DOS's DIR command, so I cant say it is a bug.2. one thing that I noticed using this with some xml files:
If you always only use it on files with a 3 character extension (3 characters after the last dot), you can change it to:
Code: Select all
[em_markfiles0]
cmd=SELECTFILES *%filepart%.???
Code: Select all
[em_findfilepart]
cmd=%COMSPEC% /V /C
param=set filepart=%N && setx filepart !filepart:~-10!
iconic=1
[em_markfiles0]
cmd=SELECTFILES *%filepart%
[em_markfiles1]
cmd=em_findfilepart,cm_wait 500,em_markfiles0
menu=Mark files with the same last 9 characters in the full name of the file under cursor
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
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