Help with regular expression and smart rule

I’ll be honest with you all - I am not very good with scripting and RegEx unfortunately.

I am trying to produce a smart rule:

  1. I have a folder with pdfs called [author]-[year]-[title]
  2. I highlight and annotate and summarize highlights to markdown
    Here i wan’t the smart rule to kick in:
  3. Move the MD-file to a specific folder
  4. Rename the MD-file to @[author][year] - annotations and highlights

Any one who have a quick idea how to produce this?

The RE might look like this
^(.*)-(\d+)-
The replacement like
@[$1][$2] - annotations and highlights

Not tested, though

Does the name contain the square brackets or is it actually author-year-title?

1 Like

No square brackets, ex.: Drotner-2000-Konvergens_og_divergens.pdf
Want MD file called: @Drotner2000 - annotations and highlights

So, my replacement RE should be
@$1$2 - annotations and highlights

The RE to split up the PDF’s title should remain the same.

2 Likes

Or @\1\2 - annotations and highlights if you want to use smart rules and Scan Name & Change Name actions.

2 Likes

Tx - I didn’t check if it’s backslash or dollar for capturing group references. Should’ve

Thank you both of you!
I did this:

But the file was just named @\1\2 - I’m doing something wrong here! :slight_smile:

Also, i just realised that some of the pdfs have more authors and in that case the pdf is called author-author-year-title - is there anyway to get around that? Otherwise it can be one of the manual edits I can do myself afterwards.

The Scan Name action looks for a string currently according to your screenshot, selecting regular expression instead should fix this.

1 Like

Thank you! Now it worked. :slight_smile: