If I want to move all files matching a tag from one folder to another, what’s the easiest way to do that? Drag’n’drop from the search result doesn’t work.
Question: Do your file names have
spaces / tabs / or quotes ??
If not, what i usually do is the following:
- Type the search
- Copy Search results (the obsidian icon option)
- !IMP! choose show path option
- Copy the list into a text file for e.g.
- Run the following shell command:
cat PATH/TO/move.txt | xargs -I % sh -c 'echo \"PATH/TO/YOUR/VAULT/%\";' | xargs -I % sh -c 'cp -rf % PATH/TO/DESTINATION/FOLDER/'
- if your names have spaces and other path breaking characters you need to search / replace all of them to escape them before running the command otherwise the paths will be broken.
- The path has to be either the absolute path or the relative path from where you are running the command. You need to replace
PATH/TO/DESTINATION/FOLDER/from the above command (keep everything else)
- I am sorry if this is not what you are looking for
- If you are using the third-party-plugin https://github.com/cristianvasquez/obsidian-snippets-plugin you can run this from inside a note within your vault just be careful where the path is currently (if you do use it, the current directory is the root).
This is from inside the note
To see where you are run the print working directory command below
You can do the same thing using python instead of sh and
**it wouldn't care about spaces / characters.**
I can share it if it is what you want please let me know.
Thanks. With 1600 files this process would probably take a lot of time. But for some reason, it made me realize that I could just use Finder to search for the relevant tags and make the move there. So, thanks!
Hello, I’d be interested if you could share how I can do that using python. I want to move a lot of notes and all of them have spaces in their titles…
+1 We need the option to select multiple files and move them to a specific folder. Or a command to move multiple files.
I’d also like this. My use case is being able to move a bunch of notes fro wherever they are to one place. This happens at the moment when I realize that they should be organized together, which is often well after they’ve been written.
Just use folders instead of trying to do technical feats with scripting… folders are not so bad. Use them to group related notes.
You’ll not lose flexibility of links, MOCs and tags… they are not mutually exclusive with folders after all.
If anyone is still interested in this, there is a great community plugin called ‘Auto Note Mover’.
It allows you to define rules for automatically moving notes into specific folders based on tags or phrases in the note title. Also supports regex.
Usually it is only triggered upon creating, editing or renaming a note.
For the purpose of moving all notes in the vault that fit a specific rule at once, there is a workaround:
- Create a new folder in the root of the vault
- Move all files and folders in the vault to the folder created in step 1 (except .obsidian, .git, etc.)
- Move the notes and folders moved in step 2 back to their original location.
This will trigger the plugin and all notes that fit a rule will be moved to the correct folder.
The workaround was proposed by the plugin developer in this GitHub issue thread.
The great thing is after the initial move you can leave the plugin turned on and it will automatically move all notes into the correct folders upon creation, so you will not have to worry about moving notes ever again!