Also sending my thanks for this plugin
I really should have read the whole thread first to see the better solutions that had already been posted. But I wrote this bash script for my own use, and I might as well dump it here:
#!/bin/bash
set -e
FROM="#context-home"
TO="#home"
# Search for all .md or .MD files in the current working directory.
# For each, do the indicated replacement.
find . -type f -name "*.md" -o -name "*.MD" | while read file; do
# If the file does not contain the FROM string, skip it.
grep -q "$FROM" "$file" || continue
echo "Processing $file"
sed -i "s/$FROM/$TO/g" "$file"
done
(I should say, really, āGithub Copilot and I wroteā. My bash/find/sed ability is weak enough that it would have taken me a good half an hour to look up the right usages on my own. AI, man.)
Iāve been searching for a solution to this, and wanted to share mine! Canāt believe I didnāt think of this before. My goal was simple: delete the tag literature
from my vault. The wonderful Tag Wrangler plugin doesnāt support deletion, but it does support renaming.
First, I renamed the literature
tag to a random string (letās say OmGsQgSzTw
, generated here). After, I opened my vault in VSCode and used their find and replace to replace all occurences of OmGsQgSzTw
with nothing. However, tags can come in a few formats, and just removing the string might not work. For instance, I replaced the strings (everything in quotes, including commas): " OmGsQgSzTw," & ā, OmGsQgSzTwā & ā#OmGsQgSzTwā. That did the trick!
In hindsight, unbelieveably obvious. I was trying to regex and script my way through it, but this is significantly easier. Just wanted to drop this for anyone else also looking for tag deletion! Of course, make backups of your vault or labelled git commits just in case, but I didnāt run into any problems. Depending on the number of notes you have, the renaming, find and replace, and re-indexing can take a little while.
+1 for tag rename, delete, organize feature
Tag Wrangler works for me, but still +1āing for this to be a core feature
Iām suprised that nobody mentioned the āGlobal Search and Replace Pluginā yet. I just deleted a tag successfully using it. For renaming tags, I use TagWrangler.
Is there a way to assign the same tag(s) to multiple notes at once?
MOD-EDIT:
Related To: Tag Mass Action: Add, Rename, and Delete a tag in multiple files (Tag Wrangler)
Other than one by one? I donāt think so, except really ugly hacks with external scripts
Yes, I meant ābatch addingā of a single tag to multiple files.
ie: You have Ford, Fiat, Chrysler, VW, Audiā¦ etc files and you want to tag them all with #carbrand
I didnāt realize something like this was not possible.
How is the list of files going to be specified?
- Selection of files in file Explorer within Obsidian?
- Files refered by collection of links within some markdown file?
- All files contained in folder and its subfolders?
Edit thanks WahWah for clarificationā.
- list copied from search results
Like in most apps where this is any easy thing: search across all notes for a subset you want to tag. Use REGEX to get said set, select all results. Use the tag option to tag all entries in the set. Done.
From https://forum.obsidian.md/t/obsidian-release-v0-9-3/6622
When using global search, you can now copy the search results file list. This can be optionally formatted as wikilinks and/or as lists.
Now it is available as last icon above search text box. I do not know if API version of this command exists.
I think this request could be best done as a plugin.
I do not know if it is better then to store it in feature-requests or plugin-ideas category.
The plugin could:
- add custom hotkeys for even faster use. Especially when Single key hotkeys (context sensitive) become supported.
- have options whether to add tags:
- to standard front-matter field ātagsā
- in some other syntax/place
- have option to insert only those tags that are not assigned yet to given note
- in YAML front-matter field ātagsā
- in some other syntax/place
Since tag support is already a core feature of Obsidian, I would argue this feature request is best implemented as a core feature. As @WahWah said, this is pretty standard in apps that support tagging.
As to the specific UI implementation, @malecjan mentions several good options. As with other file management actions, I think it makes sense to let the user do it in several different ways. Using the File Explorer and Search Results seem to be the most compatible with Obsidianās current UX.
File Explorer
First, multi-select of files in File Explorer, then
ā right-click menu āAdd tag to selected filesā
ā command palette āAdd tag to selected filesā
ā drag selected files to the tag in the tag pane OR drag the tag from tag pane to the selected files
Search Results
First, perform a search query that give results, then
ā click a new #
button (next to the ācopy search resultsā button) to assign a tag to all notes in the search results
Iām all about this feature. Iād just like to add that there also needs to be a way to REMOVE a tag. So if there is a context menu or command palette item for āAdd a tag to selected filesā, there should also be one for āRemove a tag from selected filesā.
@Gem, this may help:
By the way, an example of free software that can mass search and replace is VSCode.
Thanks
We need an interface that can manage labels systematically, and more abundant label functions.
Thank you but Iām not talking about editing or removing a tag at the global level. I meant removing a tag from, say, 5 selected files out of 100 that have that tag. Really just the inverse of adding a tag to multiple selected files.
+1 on the feature request for being able to add or delete tags in batch mode.
+1 Would love support for this too!