RegEx - Not Working with simple rename

Hi All,

I’m stumped. I just don’t know what I’m doing wrong.

I’m trying to rename some files by removing the YYYYMMDDHHMM datestring at the beginning of my filename.

I have followed the advice on DEVONthink’s website here and used RegExr: Learn, Build, & Test RegEx to confirm my RegEx is Valid (see image below).

But when I input the destination pattern. \3 (I’ve also tried $3) nothing happens.

I am able to successfully use RegEx outside of the DEVONthink environment using A Better Rename, but I am yet to find success using DEVONthink.

Is it a bug? Or am I doing something wrong?

Help and advise appreciated!

In the case of this uniform naming convention, this could be more simply done with…


Thank you @BLUEFROG, that worked on a small test. However, I just ran it on a larger batch and it removed the whole filename except the last word (much like the expected results from the screenshot below) :sweat:

As I’m still in the process of learning how to use and manipulate RegEX, could you please explain why my RegEx in the example above didn’t work in DEVONthink whereas it did in A Better Rename?

Is there something wrong with the syntax I posted above that DEVONthink doesn’t interpret?

Also, does DEVONthink not recognise $ in the destination pattern, only \?

I think the confusion arises, when trying to learn to use RegEx, there seems to be different flavours which produce different results? See below:

I’d be grateful for some clarification as to how to use RegEx in DT3, asking so I know for the future when trying to build RegEx patterns in DEVONthink.

Thank you for your help :grinning:

I hadn’t even noticed the $ but you should use \n.

Yes, there are different flavors of RegEx. As noted in the Help > Documentation > Appendix > Smart Rule Events and Actions, for the Scan Text and Scan Name smart rule actions, we use NSRegularExpression which conforms to ICU RegEx.

For the Script > Rename > Rename with RegEx, it is using the sed command, so you’d need to be cognizant of what RegEx works there.

While this may seem confusing, in normal instances such as this one, the same syntax applies.

Thank you for the info provided. I’ll take a deeper look :+1:

Ahh… /facepalm
That’s because your filename has a bunch of hyphens in it, so it matches the last hyphen.

Use this…


Note I used the ^ and $ anchors just for clarity.

@BLUEFROG Thank you, I’ll give it a gentle spin :wink:

You’re welcome.

I am running into an issue of a simple RegEx rename not working. I highlight the files that I need to rename and then choose scripts - rename using RegEx pattern.

1 - Docuemnt Name - Part
1 - Docuemnt Name - Part
2 - Docuemnt Name - Part
2 - Docuemnt Name - Part

I need to rename the digit and dash at the beginning.

None of the RegEx patterns do anything:

\d\s\-\s
\d -

This thread is four years old. Please open a new one for a new problem.

And if you do so, please explain what you mean by “None … do anything”. A regex pattern like this doesn’t “do” anything, it simply matches. If you want to change the match, you must use capturing groups and refer to them with \1 etc.