You raise a valid concern. I use an action that, when invoked, prompts for a new title for the current draft. After you provide the new title, the action updates the title of the current draft and searches the workspace updating links that depended upon the old title.
I use this action often (1) to clarify a title, (2) when I decide to split or merge drafts, or (3) simply to fix a typo in the title.
As I understand it, the same problem in The Archive is solved by making links dependent upon 12 digit UIDs in the form yyyymmddhhmm. But, other than date created, UIDs don’t convey useful information, so a link based upon a UID must be further explained - else who knows what it is a link to? Linking with titles, assuming that you have a way of updating links based on title names when a title is changed seems more efficient to me.
Hey, that’s a great script. I made a small change, so that the script counts the drafts that were changed as well, giving the total of drafts changed AND the total of drafts evaluated. Just a small sanity check for my use!
Here’s the change:
//This scripts prompts for a new title and then replaces the old title with it.//
//The script also searches the current workspace to locate links based on the old title, and updates them.//
// prompt for new title.//
let p = Prompt.create();
p.title = "New Title";
p.message = "Enter the new title. The old title and all links using that title will be replaced by the new title.";
p.addTextField("newTitle", "New Title", "", {
"placeholder": " ",
"autocorrect": false,
"autocapitalization": "none",
"wantsFocus": true
});
p.addButton("Replace");
if (p.show()) {
//Establish variables for the old and new titles and the old and new links.//
let oldTitle = draft.displayTitle;
let oldLink = `[[${oldTitle}]]`;
let newTitle = p.fieldValues["newTitle"];
let newLink = `[[${newTitle}]]`;
//Search the current workspace looking for links based on the old title and update them.
let count = 0
let cCount = 0
var drafts = app.currentWorkspace.query("all");
for (let d of drafts) {
if (d.uuid != draft.uuid) {
if (d.content.includes(oldLink)){
d.content = d.content.replaceAll(oldLink, newLink);
d.update();
cCount++
}
count++
}
}
editor.setText(editor.getText().replace(oldTitle, newTitle))
alert(cCount + " changed in " + count + " drafts evaluated.");
}
I think you will have better luck starting with the group that @agiletortoise provided in the Action Directory when Version 20 was released. It is called “Examples: Cross-linking” and has actions for:
Insert Link to Draft
Back Links
Open Last Draft
New Linked Draft (which I renamed to New from Structure Note)
The one additional action I think you’ll need is “Title and Links” which I shared to the Directory yesterday. It changes the title of a draft and also updates any links dependent upon the new title.
I use Bear and wanted somewhere to store other file types. So I added a single step text action where the clipboard holds the title of a Bear note.
[[bear:[[clipboard]]]]
I added “Markdown Link” – also provided by @agiletortoise to this action group.
You may want to modify the template used by “New Linked Draft” or duplicate that action to provide more than one template option. I provided an example of how to do that earlier in this thread.
“The Archive” is a software product designed from the start for use with a ZK. The developers run a site devoted to ZK use. You can learn from some of the discussions, but you can also get lost in what seem to me to be theoretical distinctions of no great importance.
I first experimented with a ZK using The Archive. But, with Version 20, Drafts emerged with much more ZK-related functionality. At this point, The Archive’s functionality is a sub-set of what Drafts offers, both for ZK purposes and for a lot of other things.
On the other hand, The Archive developers are good sources for improving your understanding of how a ZK is supposed to work – particularly if you are an academic.
thanks for that context. that is often a great misunderstanding. as a software engineer with a documentation stream and a dad of four / philosopher / soul pilgrim at night my Zettelkasten requirements are very different then those of a academic scholar (is scholar the right word?)
I am working with a mixed system (drafts and paper) - we will see how this works out.