Moving all files in a search result to new folder

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.

1 Like

Hello,

Question: Do your file names have spaces / tabs / or quotes ??

If not, what i usually do is the following:

  1. Type the search
  2. Copy Search results (the obsidian icon option)
  3. !IMP! choose show path option
  4. Copy the list into a text file for e.g. move.txt
  5. 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/'

P.S:

  • 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/ and PATH/TO/YOUR/VAULT/ and PATH/TO/DESTINATION/FOLDER/ from the above command (keep everything else)
  • I am sorry if this is not what you are looking for

Edit 1:

This is from inside the note

To see where you are run the print working directory command below


Edit 2:
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.

2 Likes

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! :slight_smile:

3 Likes

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…