Use regex with clipboard content

Hi,
I am looking for a solution to get a segment (the digits) of the current foldername to be copied to the clipboard without selecting a file or folder.
All folders and subfolders I use have 4 or 5 digits in the name like "12345-example name" or "test 12345-example name"

With the clipboard set command I can retrieve the current foldername without selecting any folders or files:

@nofilenamequoting
Clipboard SET {sourcepath$|nopath|noterm}

Result clipboard: "12345-example name" or "test 12345-example name"

I already have a solution to accomplish copying those digits to the clipboard by selecting the mainfolder or a subfolder, but that means I always have to select something first.
For that I use:

Clipboard COPYNAMES=nopaths REGEXP "([0-9]{4,5}).[^.]" "\1"

Result clipboard: "12345"

Is it possible to use the regex trick with de clipboard SET command, and thus getting those digits in the clipboard without having to select anything first?

Adding FILE={sourcepath$} will make the command you have work on the current folder, without needing a selection:

Clipboard FILE={sourcepath$} COPYNAMES=nopaths REGEXP "([0-9]{4,5}).[^.]" "\1"
1 Like

Hi Leo,

Many thanks!!

1 Like