GP SoftwareTwitter
Opus FAQsManualCommandsObjects

Select part of a filename and put it in copy buffer

Hey all,
I come seeking scripting (perhaps) help. I'd like to extract the date and time from screengrabs. They'll look like this:

chrome_2020-08-02_02-18-12.png
Layout_2020-08-01_12-43-46.png

and I'd like to select the:
08-02_02-18
08-01_12-43

bits and put the resulting text in the copy buffer. I will only be selecting one file at a time, I just have a couple selected here to show the exact part I want to select in files differently named to start with. I know I can copy a filename with Clipboard COPYNAMES=nopaths but I'm not sure how to extract the characters I need. Can I use Regex here?

Hope you're all well, and staying safe in Covid land...

All the best,

B

Can I use Regex here?

Yes.

Clipboard COPYNAMES=nopaths REGEXP ".*\d\d\d\d-(\d\d-\d\d_\d\d-\d\d)-\d\d\..*" "\1"
1 Like

Well, that was a short thread! :smiley: Thank you lxp, your Regex worked perfectly.

B

1 Like