Regex script do not rename file


I’m trying to batch rename some articles. Many starts with the publication year, and I’d like to include the work Artigo as a prefix, and use underscores to separate the prefix and the year.

I’ve never used Regex before, so I practiced in python using a jupyter notebook. After a few tweaks, the code worked fine:

oldtitle = “2003 Five Tenets of Security-Aware Logistics and SC operation”
newtitle=re.sub("(^\d{4})\s",r"Artigo_\1_", oldtitle)

The resulting title is Artigo_2003_Five Tenets of Security-Aware Logistics and SC operation.

However, when I try to do the same using the Regex script from DVT 3, nothing happens. Did someone have the same issue?

Best regards

What did you enter as the source pattern?

Also, you said…

Many starts with the publication year

So you’re not processing files without a year at the beginning?

Hi, Bluefrog.

I tried the Regex in files that start with the year.

I tried the Regex

But what did you enter?

I tried the simplest form:

1st dialog box (search): ^\d{4})\s
2nd Dialog box (replace for): Artigo

Note: There are several flavors of Regex in the world.

This works…

With & representing the matched value here.


Thanks a lot!

If I may ask you for a little more help, I’d like to remove the space after the last underscore.

I tried ^([0-9]{4})[ ] in Devonthink, to select the year + the space, but only save the year for later use. It didn’t work. The space stays there.

Do you have any suggestion?


Use capturing groups and backreferences then…