Extracting specific text from folder name

I have folders of the following format:

2019-04-16c COM0041224 Maybe some text maybenot
2019-04-16b COM0040012
2019-04-15f COM0039195
2019-04-15e COM0038844 Blah blah
2019-04-15c COM0041907
2019-04-15c COM0041097
2019-04-15b COM0041401 Qqssss
2019-04-15a COM0034642 Blahstuff

I want to add a context menu so that when I rhs click a folder I have a new men item which extracts the COM00XXXXX number from the folder name and sends it to the clipboard.
I am frequently surpised at the power of internal commands, happy to be surprised again if this is internal commandable.
I am assuming it is scriptable.
Posting this now in the hope of feedback about which route is feasible
Any comments appreciate as always.

This works for me but I'm sure there are cleaner ways to do it:

Clipboard COPYNAMES FILE REGEXP (COM\d{7}) \1

I'm assuming you know how to add it to the Right Click menu?

1 Like

Thanks blueroly I will take that and play
I do indeed know how to add that to context menu.
Just tried it.....amazing... thank you!!!

1 Like

This is so freeking cools man!!!!
I was expecting a major project!!!!!!!

Gratitude, thankfulness, or gratefulness, from the Latin word gratus ‘pleasing, thankful’,[1] is a feeling of appreciation felt by and/or similar positive response shown by the recipient of kindness, gifts, help, favors, or other types of generosity, towards the giver of such gifts.[
- Wikipedia

3 Likes

Comrades
I reference to this stupendously useful internal command:

Clipboard COPYNAMES FILE REGEXP (COM\d{7}) \1

Q1 Am I right in saying there is a single internal command namely clipboard at play here?
Q2 COPYNAMES and REGEXP are clipboard internal command arguments
Q3 I cannot find any reference to a FILE argument. Is it doing anything? The whole command seems to work on files and folders without the FILE part

Q1 - Yes.

Q2 - Yes as well.

Q3 - The Clipboard command's FILE argument is documented in the manual, but not really being used in this example, since no file path is specified after it. It's harmless, but shouldn't really be in the example. Probably something left-over from where the original command line was used for something else.

2 Likes