Global (Mass / Vault-wise) search & replace

There is another possibility I don’t think I saw mentioned. For those of you who know and love vim, all you need to do is put the obsidian editor into vim mode and you have a complete search and search and replace mode ready and waiting for you. No plugins or set up needed

2 Likes

I’ve been searching around the forum to find a solution for changing all the tags in a vault into backlinks. This thread seems close enough.
I have imported my notes from evernote, I have around hundred tags to change into backlinks because I want to change the way I work with tags.

I’m on Windows, I could use a tool like Notepad++, but I don’t know how to write a regex for that.
Anyone have a clue? Regex or any other solution that would not be changing tag by tag?

Thanks

1 Like

+1. I can see using this to replace the file path of linked external media if the folder it’s kept in has to get moved (i.e. if I were to move that folder of photos, etc. from the desktop to an external hard drive)

1 Like

+1, please :upside_down_face:

1 Like

+1, we really need this function.

1 Like

Yes, such a feature would be great. I was just searching if there was a way when I found this thread.
However I did not see this as a big deal, I used the Open vault in VSCode button for Obsidian.md plugin from @NomarCub and searched & replaced within seconds.

4 Likes

I did this too. It helped me to save a lot of time.

+1, would be really useful for renaming tags or file links en masse

2 Likes

+1 Come on. Basic functionality.

2 Likes

A specific function to rename tags would be nice too.

3 Likes

+1

rename tag is a useful function

1 Like

There are already plugin for renaming tags: tag wrangler.

2 Likes

So far I’ve been opening my Obsidian vault in Atom to do global search + replace. I saw just now that Atom is going to be discontinued, if I understood that correctly. So has there been any update on doing this in Obsidian?
Thanks :slight_smile:

2 Likes

I use a shell script for this bulk replacement

on MacOS:

#!/bin/sh
ORIG='text_to_be_replaced'
REPL='new_text'

find . -name '*.md' | xargs -r sed -i '' "s/$ORIG/$REPL/g"
4 Likes

Thanks, I’ll give that a try. I’m on Linux Mint, but I think I’ve used something like that before.

How do I limit that to certain folders with subfolders/recursively?

Based on my understanding, the . means current folder where the shell script is executed. And you can replace it with some other path.

Second, find will go through all subdirectories recursively by default.
And if you want don’t want find to go into the subdirectory, you can use -maxdepth to limit the maximum depth that find will go.

find . -maxdepth 1 -name '*.md' | xargs -r sed -i '' "s/$ORIG/$REPL/g"

Oh, one more very important thing:

Make a BACKUP first.

when the script runs, there is no returning back.

2 Likes

Haha yeah, backups are good, but thanks for the reminder :slight_smile: That’s kinda why I was hoping for an implementation in Obsidian like it is in Atom as I find that harder (not impossible though lol) to screw up.

Thats exactly the reason I have SVN installed.
I commit my notes everyday, just in case I have to fallback.

But even otherwise , SVN + Obsidian give you insight how the note/s have emerged/branched over time.

I use freesync to backup obsidian vault everyday to a specific folder, so that the time machine will continue the backup work.

1 Like