Hi all. Long time lurker, first time poster. I have wanted an automated way to compile transcluded notes together rather than having to manually copy pasta a bunch of notes together. So, I created an iOS Shortcut that can do it for me. It is very simple and potentially inefficient so take care when you try it out.
I say this a few times: It should NOT alter any notes involved but instead create a new merged note made up of the text.
Everybody does their notes differently so this may or may not work for you. Or it may be a good starting point for you to handle your case. Either way, sharing is caring.
Here’s the iCloud link. Explanation of how it works follows.
Shared note: note shared into the shortcut
Merged note: resultant compiled note from shared note and transcluded notes
Transcluded note: any note referenced by
“![[note name]]” in the shared note
How the shortcut works
On import of the shortcut, you are asked two questions.
- Where to source your note files
- Where to save them
For 1, I use my base Obsidian vault folder. if your database is huge, this may result in slower response times because of how the Shortcut gathers note file references.
For 2, it will default to your Shortcuts folder but you can save it wherever Shortcuts has access.
This shortcut accepts selected text from within a note or a note file from within your Obsidian vault. If neither are provided, it will prompt you to select the file you want to compile.
It will then parse through the shared note text to match any
![[note name]], including any with an “|alias”, text in the body. When found, the shortcut will find that transcluded file by file name in the source folder you provided on import and grab the text of it. In the shared note text, the
![[note name]] text is replaced by the text of the transcluded note.
There are some important caveats for how this works.
- In order to work, the shortcut has to gather a list of all the notes that could be transcluded in the note you’re trying to compile. If you know that your notes are only in a subset of folders, you can select that folder for the first import question instead of your base vault folder.
For me, I set it to be the base vault folder. With about 500 notes in the database, it takes about 5 seconds to gather those files for reference later in the shortcut. YMMV.
This will only work with ONE LAYER DEEP of transclusion. If your transcluded note has transcluded notes, this will NOT gather those notes. I do not intend to add that any time soon because it makes the shortcut FAR more complex, more complex than my personal needs and potentially beyond my skill set to accomplish readily.
Both the supplied note and the transcluded notes will NOT be edited. The text is just taken from them and merged together within the Shortcut itself. The compiled note is saved to the folder location you set in the second import question.
There are probably more efficient ways to do what this is doing; so, if you figure any out, feel free to drop a comment. I may be able to help you make changes for your particular setup but can’t promise anything.
I’d recommend you test this before using it seriously just in case. Again, it should not edit any existing files but sometimes Shortcuts does weird things.