Linking all notes in a folder

Hope all is well,

I have imported all of my 1,000+ notes from Apple Notes into my vault into a folder. It bothers me that they aren’t all linked together on the graph, is there a way where I can automatically link all of these together, and make them connect in graph view? Without going through all 1,000 notes and backlinking them all.

Thank you!!

What I would do is use the front matter to add a tags property to each of those notes and give them all the same tag, for example, #AppleNote.

In the graph, you can make the tags appear as nodes, and then they would all be connected to that single node.

Of course, this means editing all 1000 notes to add the tag, but it’s something that can be easily automated with a script.

1 Like

You can make a note in each folder with the same name as each folder, and link to the notes in the folder from there.

The Folder Notes plugin can make keeping the names in sync easier, and can make the pair appear to be a single item in the file browser if you want.

I don’t recall if Folder Notes had a way to put those links in automatically. If not you could use a base (Bases with Folder Notes) or something like the Waypoint plugin.

1 Like

Thanks! I was able to do this with the script I wrote here:

(async () => {
const folder = “Apple Notes Import”; // ← change this to your folder path e.g. “Notes/AppleImport”
const tag = “#AppleNotes”;
const files = app.vault.getFiles().filter(f => f.extension === “md” && f.path.startsWith(folder + “/”));
const results = ;
for (const f of files) {
const content = await app.vault.read(f);
if (!content.includes(tag)) {
let newContent = content;
if (content.trimStart().startsWith(‘—’)) {
// attempt to insert after closing frontmatter
const fmClose = content.indexOf(‘\n—’, 3);
if (fmClose !== -1) {
const afterFM = content.slice(fmClose + 5); // skip newline—\n
newContent = content.slice(0, fmClose + 5) + tag + ‘\n’ + afterFM;
} else {
newContent = tag + ‘\n’ + content;
}
} else {
newContent = tag + ‘\n’ + content;
}
await app.vault.modify(f, newContent);
results.push({path: f.path, changed: true});
} else {
results.push({path: f.path, changed: false});
}
}
console.log(“Done. Results:”, results);
})();

I ran it in the dev console and it added the tag to all of the notes, so thanks for the suggestion!

1 Like

Thanks, this worked with the script I posted.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.