Create Rule to Move a Tag pattern to a custom field or have custom filed on Web Clipper

Hi there, when web clipping, I am trying to associate my web clippings with a custom field, “CitationKey.” I don’t see that adding custom fields to the web clipper is possible. Is this possible? If it is not possible, is there a way to create a rule that would transfer any Tag proceed by an “@” to the custom field “CitationKey” and remove the @ from the tags? See the image below, for instance. I’d like to move @Becker2022 to the customer field, “custom metadata”, to CitationKey.

Or, could I add “@Becker2022” to the comment and then have DEVONThink use RegEx (e.g., “\B@\w+”) to parse the citation in the comment into the CitationKey custom metadata field.

Thanks for the inquiry!

  • No, you cannot assign custom metadata in the clipping extension.
  • Neither Tags nor Comments are processed via RegEx.

You could only accomplish this with an Execute Script action.

  • Is the key supposed to include the @?
  • What if there is more than one @ tag?

Like so…?

Thanks. Not sure what an “execute script.” The @ is not absolutely required, but it is my convention to use it; also, I don’t know who I’d eliminate a citation from other text in the comment. I"m assuming the execute script could use RegEx to parse a comment yet? How does one write an execute script?

Execute Script is a smart rule action.

The @ is not absolutely required, but it is my convention to use it;

But are you preserving the @ in the metadata?

I"m assuming the execute script could use RegEx to parse a comment yet?

While it could, it’s not an avenue I’d take. RegEx isn’t something built into AppleScript.
Also you were initially referring to using tags, so that’s the road I’m going down.

And does my example look correct to you?

Yes, ideally.

Ah, I see. When you say “Execute Script” you’re referring to execute an “Apple Script”. This makes sense. 95% of the time there will be only one citation tag, e.g. @Becker2023 or @Bluefrong2023. My workflow will pull in other others and tags as necessary; however, if there were multiple stages I’d like to have them show up in CitationKey as a semicolon-delimited list.

Sadly, I have little/no experience writing Apple Script. Are you aware of an DEVONThink tag parsing Apple Script that I can leverage/modify? And, once I had it how would I use it in DEVONThink? I’ve never setup an Apple Script in DEVONThink.

But it’s built in JavaScript, and that can be used to write scrips, too. Just saying.

That’s a misconception, since across can also be written in JavaScript.

Here you go…

  1. Unzip it.
  2. Double-click the .dtSmarttRule to install it.
  3. At the bottom of the Navigate sidebar, double-click the Tags to Metadata smart rule and set the appropriate location in the Search in dropdown. For example, the Global Inbox or the database you’re clipping to.
  4. Clip to the location using the @someTag convention then check the Custom Info inspector.

Tags to Metadata.dtSmartRule.zip (1.7 KB)

PS: This preserves the tags in their @format. This could be modified, if needed, but it seems like a good visual to know what tags are used in the custom metadata.

Oh, this is Awesome!!! Thank you so much. Question, is there a way to keep the “@” in the citation when it is added to the custom field? Also, I noticed if there is more than one a space is added? Is there a way to not have this extra space? Thank you!

image

UPDATE: Never mind, I got it. :). Remove the space in mdDelimiter and do -0 in the script.

One other question, this one I don’t think I’ll be able to figure out. How do I have the Apple Script remove the citations from the Tags?

Yes, it’s possible but are you sure you want to remove those tags?

do -0 in the script.

Post what you’re referring to.

I tried the -0 actually and it does not seem to work. The script keeps deleting the -. I’ll try a bit later. it seems to take a while (few minutes or more for the script to take effect, even after applying it).

You caught me. :slight_smile: No, I’m not sure, but then again I don’t think I want 100s and thousand of this floating around, but then again it would help for filtering all articles with the same citationkey.

Got it, I can remove this " characters 2 thru -1 of" and then the @ is not deleted. :slight_smile:

Well done :slight_smile: It’s good to learn such things :smiling_face:

1 Like

You’re a good teacher. :slight_smile: Thanks!!!

1 Like