Things I have tried
I apologize if this has been asked before
I’ve look through community plugins and the obsidian forum for solutions but didn’t find anything
What I’m trying to do
I want to automatically scan through a note and send particular sentences to other notes:
For example if this sentence was tagged with $#reference it would be sent my reference note
Ideally I would be able to set which tags would send to which notes and even send to sub heading within notes
One possible approach: I have a QuickAdd (community plugin) macro that lets me press a keyboard shortcut and move the line I’m on to a specific section in my daily note. I have very similar one tied to a different keyboard shortcut that will open up the Quick Switcher for me to select a file and then move the line I’m on to the same pre-specified section in that note instead. (I use this for sending to other day’s notes. It would definitely break if I selected a file that didn’t have the section name that the macro sends it to.) This approach works for me because I like the idea that my files will not change unless I explicitly command them to (via the keyboard shortcut). If you’d prefer to type a tag to trigger the move I have no idea how to do that part.
I hope other folks can share their approaches and that between all of them you’ll find something that sounds good!
You can do this with the dataview plugin and inline metadata, mostly. If you can separate the sentences that need to be sent onto their own lines, you can do it like this in your notes:
reference:: Here is a sentence that should appear in another place.
differenttopic:: This sentence should appear in a different place.
reference:: This sentence should appear in the same place as the first, and it’s a little longer, but that’s okay.
And then in your reference note, you can put this dataview code:
$=dv.list(dv.pages('"original/notes/folder"').where(p => p.reference).sort(p => p.file.name, 'desc').map(p => p.file.link + " " + p.reference));
And in the reference note, you’ll get:
link-to-file Here is a sentence that should appear in another place.
link-to-file This sentence should appear in the same place as the first, and it’s a little longer, but that’s okay.
Hope that helps!
Try Obsidian 42 – Text Transporter. It is not automatic, but it has many options and works well.
Awesome, thanks for the tip! I’ll try this out now:
Just a few questions:
Do I just copy paste the dataview code into my reference note as is? or do I need to alter it in some way? ie. change the “original/notes/folder” to the folder path of my source note?
Would this code run automatically or would I need to trigger it somehow?
Thanks for the help
The code does just get put right into your note, but you’ll need to enclose the code in backticks, and there are two ways to do that:
One is in a block, where you start with 3 backticks and the word dataviewjs [```dataviewjs] and then the code on the next line (starting with “dv.list…” - take out the “$=”) and then three more backticks on the next line.
And the other way is inline, where you would copy my code exactly (keeping the $= in front) but you’ll need to enclose that in single backticks. So one backtick just before the $ and one backtick just after the last semicolon. (The forum renders them as code, so I can’t type them in!)
And make sure you’re using backticks, not single quote marks! (On my keyboard, the key is to the left of the 1/! key.)
And yes, you’ll need to change the path in the code to the folder where the notes that you want to pull the comments from are. So for me, I am pulling stuff out of my daily notes, which live in a folder called “Journal”. So that bit looks like [dv.pages(’“Journal”’)] for me. It will go down into subfolders - like I have mine organized into months - so you don’t need to specify every subfolder, just the top level one.
So the basic gist is that somewhere in one of my daily notes, there is text that looks like this:
coolthing:: My husband made the best lamb stew last night!
And then somewhere else (doesn’t have to be in the same folder), I have a note called Cool Things.md and all that is in that note is the code I pasted above (with ‘Journal’ in the path and ‘coolthing’ replacing ‘reference’). But when I look at that note in reading and/or live preview editing modes, I’ll see the list of coolthings that have been pulled from my daily notes. It is just there - you don’t have to do anything or run anything to see it.
Hopefully that gives you enough to go on! Enjoy!