Title and Links no Longer Working

I’d like to suggest some additional revisions having dealt with identifying the wide variety of links in Drafts before in some of my own link management actions.

More Links

When working with a link, I believe these are all valid title-based links to the same draft:

  1. [[Master Plan]]
  2. [[d:Master Plan]]
  3. [[Master Plan/Step 1]]
  4. [[d:Master Plan/Step 1]]

Looking at the code in the original action, I appears it would only identify and update the first of these links.

let oldTitle = draft.displayTitle;
let oldLink = `[[${oldTitle}]]`;
...
d.content = d.content.replaceAll(oldLink, newLink);

Given this could actually cause a degredation of data, I think this would be a very worthwhile revision, anf perhaps one that @jaymf or @Mike_Burke would like to pick up as active users of the action? If the action does one replacement, it would just be a case of also doing other replacements.

I reckon you could do it with a modification to the value of oldLink and one alternative. Unless you want to go the regular expression route, in which case, I reckon just one replacement would be required :wink:

Further Query Constraints

The suggested workspace query searches only for the title text, so that is not impacted by the structure of the links discussed above, but it may still be pulling in more drafts to process than is strictly necessary. It would also pick up drafts containing the words of the title where they appear, but are not linked.

ws.queryString = `"${oldLink}"`

In most cases, for most people, I think this would be minimal overhead, but the reality is that it comes down to the original name of the draft and the previously spoken about draft volumes … hopefully it would not simply have been labelled “note” in amongst thousands of drafts about note taking :scream:

I’ll leave it to others to decide if it is worth the effort of narrowing things down in that search (it would make a good exercise of course), but the advanced query options do support options like Boolean operators and of course our favourite, regular expressions.

There may be other enhancements too. These points were just ones that occurred to me as I skimmed the thread and the code. Anyone up for taking a closer look and seeing if they can enhance and optimise things a little?