i have this script for obsidian <%* const quoteFiles = []…
- User
i have this script for obsidian <%* const quoteFiles = []
codeapp.metadataCache.getCachedFiles().forEach(filename => { // get all filenames in the vault and iterate through all of them, calling a function for each of them let { tags } = app.metadataCache.getCache(filename) // get the tags in the file w/ the given name tags = (tags || []).filter(t => t.tag && "#quote" === t.tag) // filter out all tags that are not "#quote" if (tags.length > 0 && filename.startsWith("(QUOTE)")) { // list will contain at least one tag for the relevant notes, also filter out all notes that dont start w/ "QUOTE" quoteFiles.push(filename.slice(0, filename.length - 3)) // cut off last three characters from filename, otherwise the links would contain `.md` at the end } }) const randomIndex = Math.floor(Math.random() * quoteFiles.length) tR += `[[${quoteFiles[randomIndex]}]]`%>
someone give me a piece of code to edit the previous code, so the templater would search for my whole obsidian vault and not just the root
if (tags.length > 0) { // list will contain at least one tag for the relevant notes, also filter out all notes" questionFiles.push(filename.slice(11, filename.length - 3)) // cuts off "(QUESTION) " AND the last three characters from filename, otherwise the links would contain
.mdat the end }// gets the full question title for correct backlinking if (tags.length) { actualquestionFiles.push(filename.slice(0, filename.length - 3)) }
i dont know to edit the original code with the second code, do that for me
- Assistant
- User
i forgot to say, i dont want any of the question stuff, i just need the quote stuff, while searching for the entire vault, including notes inside folders and not only the root, edit the code for me
- Assistant
Understood! To ensure that the script searches the entire Obsidian vault, including notes inside folders, you don't need to modify the iteration over
app.metadataCache.getCachedFiles()because this method already handles all files in the vault.Here is the simplified and updated script for handling only the quote functionality:
js - User
returned template parsing error
- Assistant
I apologize for the inconvenience. Let's try refining the script to address the parsing error and ensure it works properly within the Obsidian Templater plugin. Here's the revised script:
- User
look, lets just do it differently i have a daily notes using template, i want to everytime i create a new daily notes it gives me a random quote that i have on my vault for this i want to have a single note with all my quotes, one each paragraph can yoiu write me a script for that?
- Assistant