quickadd
quickadd copied to clipboard
[BUG] Move tagged notes macro doesn't display folder picker
The macro for moving tagged notes to a folder is broken because once you've selected Yes/No on nested tags, the folder chooser just doesn't appear.
Additional context I thought it might be because I had turned off the File Explorer core plugin, which has the Move Note hotkey bundled, but I tried turning it back on and it didn't fix it.
Hey @jacklaing, thanks for your report!
I'm having a hard time reproducing this. Does it give any errors? Maybe in the console?
Hi! Looks like I have similar issue. I can send you errors from my console log
C:\Users\user\knowledgebase\Scripts\move.js:23 Uncaught (in promise) TypeError: fileCache.frontmatter?.tags?.split is not a function
at VM551 C:\Users\user\knowledgebase\Scripts\move.js:23
at Array.forEach (<anonymous>)
at moveFilesWithTag (VM551 C:\Users\user\knowledgebase\Scripts\move.js:11)
at async MacroChoiceEngine.onExportIsFunction (eval at <anonymous> (app.js:1), <anonymous>:9669:23)
at async MacroChoiceEngine.userScriptDelegator (eval at <anonymous> (app.js:1), <anonymous>:9653:17)
at async MacroChoiceEngine.executeUserScript (eval at <anonymous> (app.js:1), <anonymous>:9648:9)
at async MacroChoiceEngine.executeCommands (eval at <anonymous> (app.js:1), <anonymous>:9622:17)
at async MacroChoiceEngine.run (eval at <anonymous> (app.js:1), <anonymous>:9615:9)
at async ChoiceExecutor.onChooseMacroType (eval at <anonymous> (app.js:1), <anonymous>:12585:9)
at async ChoiceExecutor.execute (eval at <anonymous> (app.js:1), <anonymous>:12561:17)
(anonymous) @ C:\Users\user\knowledgebase\Scripts\move.js:23
moveFilesWithTag @ C:\Users\user\knowledgebase\Scripts\move.js:11
async function (async)
callback @ VM545:12737
yS @ app.js:1
t.onChooseItem @ app.js:1
t.onChooseSuggestion @ app.js:1
t.selectSuggestion @ app.js:1
e.useSelectedItem @ app.js:1
(anonymous) @ app.js:1
e.handleKey @ app.js:1
e.onKeyEvent @ app.js:1
I tried to run this macro inside default Obsidian Help vault and it worked out properly. So, I decided to switch off all community plugins on my vault and tried again, but problem is the same, doesn't work.
In my case, tag descriptions in YAML frontmatter like:
tags: [tag1, tag2]
or
tags:
- tag1
caused the same problem. Worked properly after removing the above types of tags inside my vault.
I can confirm all of the above:
- It worked in Help vault
- I got the exact same console error as @arumazu
- As with @twakas case, it was frontmatter of the format
tags: []
that was causing the issue. Once I deleted the offending frontmatter the folder picker appeared properly. Luckily I don't use frontmatter and it was just an example page.
I was trying the plugin just now, initially the picker didn't work, but after a reload, it did.
So everything works for me now. Just for everyone's information (I was maybe dumbo)
Copy the code using the button only :D Else it adds some spaces here and there. Messes up the code and adds additional spaces to the new file path.
In my case, tag descriptions in YAML frontmatter like:
tags: [tag1, tag2]
or
tags: - tag1
caused the same problem. Worked properly after removing the above types of tags inside my vault.
Hi, I am having the same issue. How did you manage to transform your frontmatter tags to inline tags in you whole vault ? I've tried to find a way with Regex and VSC but without sucess...
I was also wondering if it would be possible to modify the js script to make it work with frontmatter tags ?
Update on this? still the same for me
I also have hit the same issue myself.
Developer console has the following:
VM145:23 Uncaught (in promise) TypeError: fileCache.frontmatter?.tags?.split is not a function
at eval (eval at getUserScript (eval at <anonymous> (app.js:1)), <anonymous>:23:67)
at Array.forEach (<anonymous>)
at moveFilesWithTag (eval at getUserScript (eval at <anonymous> (app.js:1)), <anonymous>:11:11)
at async MacroChoiceEngine.onExportIsFunction (eval at <anonymous> (app.js:1), <anonymous>:11649:23)
at async MacroChoiceEngine.userScriptDelegator (eval at <anonymous> (app.js:1), <anonymous>:11632:21)
at async MacroChoiceEngine.executeUserScript (eval at <anonymous> (app.js:1), <anonymous>:11613:9)
at async MacroChoiceEngine.executeCommands (eval at <anonymous> (app.js:1), <anonymous>:11583:17)
at async MacroChoiceEngine.run (eval at <anonymous> (app.js:1), <anonymous>:11576:9)
at async ChoiceExecutor.onChooseMacroType (eval at <anonymous> (app.js:1), <anonymous>:15884:9)
at async ChoiceExecutor.execute (eval at <anonymous> (app.js:1), <anonymous>:15860:17)
eval @ VM145:23
moveFilesWithTag @ VM145:11
async function (async)
callback @ VM105:16036
WR @ app.js:1
t.onChooseItem @ app.js:1
t.onChooseSuggestion @ app.js:1
t.selectSuggestion @ app.js:1
e.useSelectedItem @ app.js:1
(anonymous) @ app.js:1
e.handleKey @ app.js:1
e.onKeyEvent @ app.js:1
manager.ts:100 Uncaught (in promise) TypeError: Cannot read property 'undefined' of undefined
at DataManager.setTotalStats (eval at <anonymous> (app.js:1), <anonymous>:5939:21)
at eval (eval at <anonymous> (app.js:1), <anonymous>:6225:34)
Same issue here. So how to solve it?
If any of you guys really needs to move/copy notes based on tags (or any metadata used in Obsidian), I might have a workaround to offer. Here's the instructions :
-
Assuming :
- You are on Windows
- You are using the wikilinks with the shortest path when possible in your vault
- None of your file have the same name especially regarding attachments (all unique file name)
-
Select the desired filter in the Obsidian search to find the files to move or copy (path, tags, file name, content, ...)
-
Search it in Obsidian search. Copy the result with the following config :
- Show path : Off
- List style : Wikilinks
- List prefix : Any
-
Paste the result in a buffer note.
-
Paste the following Dataview "script" in the same buffer note :
```dataview
list WITHOUT ID file.outlinks from outgoing([[#]])
```
(Details: Will return a list of the files linked within the notes that resulted from your query (the links you pasted in the buffer note). This includes attachements linked in them. Which is why this step is necessary.)
- Note: This method can be used to extract all files linked to a map of content (MOC) for instance with the possibility to go multiple level deep (
file.outlinks
->file.outlinks.outlinks
-> ...)
-
Select and copy that list. Paste it in your buffer note.
- Note: The copied list might contain duplicate but this will be automatically addressed in the next steps.
-
Using multi cursor, you want to :
- Put each file name in double quote
- Note: If one of the note in your list as its name contained in another of your note that you don't necessary want to send (ex.
MOC
also inBiology MOC
), it might be best to try to add.md
to your note name OR to manually verify for this issue in the search result of step 8.
- Note: If one of the note in your list as its name contained in another of your note that you don't necessary want to send (ex.
- Add
OR
between each file name and place them on one line. Add your resulting line in afile:()
operator.
- Put each file name in double quote
Example :
note1
note2
note3
note4
"note1"
"note2"
"note3"
"note4"
"note1"
OR "note2"
OR "note3"
OR "note4"
file:("note1" OR "note2" OR "note3" OR "note4")
-
You now have a query that will return you your files and their attachements. Input it in the Obsidian search.
- Note: If needed you can add other operator to make sure your only get the notes you want to share
- Ex. Add
-path:(<path to folder with things you do not want to share>)
or-tag:(<tags to exclude>)
- Ex. Add
- Note: If needed you can add other operator to make sure your only get the notes you want to share
-
Once again copy the search result from the Obsidian search. This time, use this config :
- Show path : On
- List style : None
- List prefix : None
-
Paste it in a new note. We will name it
file_list
. Note the path of this note on your computer. -
Prepare the list :
- Using multicursor or search and replace, add the missing part of your file path so each of them end up with an absolute path instead of the initial relative path. In other word, add the location of your vault on your computer at the beggining of each line.
- Ex.:
/path_to/file.md
=>C:\User\rest_of_path_to_vault/path_to/file.md
- Ex.:
- Using search and replace, fix the slashes in your path (
/
->\
)
- Using multicursor or search and replace, add the missing part of your file path so each of them end up with an absolute path instead of the initial relative path. In other word, add the location of your vault on your computer at the beggining of each line.
-
Open a terminal running PowerShell Core 7
- From my experience regular PowerShell can very well do the job UNLESS your file name includes emojis.
-
In the terminal, change directory to the location of your file (
file_list.md
).
Example:
cd "C:\Users\path_to_my_vault\myVault\any_folder_leading_to_file_list.md"
- Use the following script and adjust it to your need.
- Note: This example is configured to copy the notes. If you want to move them instead, replace
copy-item
bymove-item
.- Be aware that moving notes in Obsidian can be problematic namely if :
- The names of you notes are not all unique.
- You are not using the wikilink with the shortest path when possible.
- Be aware that moving notes in Obsidian can be problematic namely if :
- Input the location of the folder you want to send these files to after
-Destination
in double quote as shown bellow.
- Note: This example is configured to copy the notes. If you want to move them instead, replace
Get-Content .\file_list.md | Foreach-Object { copy-item -Path $_ -Destination "C:\Users\path_to_folder_to_move_or_copy_files"}
- Run the script.
Granted it is somewhat cumbersome so it should not be something you have to do too often but once in a while, when you want to share part of your vault with a high level of precision in selecting the notes, it can be great !
Final note: Keep in mind I putted up this little explaination quickly so their might be some variant/use case I haven't tested that could be problematic (for example see things related to moving notes outside the vault) so be careful before running these and maybe test it first with some dummy notes and do back ups of your files.
I hope it can be of use to some of you !