Properties Wrangler: Add a way to "Insert", "Rename" and "Remove" properties and values in all files

+1 on this request – I’m working on a large writing project and started using a “concepts” property and sometimes several notes in, the variable that I used as the concept property becomes a MOC so then I have a linked MOC version of the variable and a variable that is unlinked term so I have to manually go back and find all the files with the unlinked variable and manually change them to the linked MOC. A way to do all of this through the overarching menu on the side would be fantastic!

1 Like

I have recently started using VS code - how are you doing this?

1 Like

Here’s a workaround using templater, made by @"quote" on Discord: Discord

They added this disclaimer though:

so in theory you could use this for all of those “oh no, my Frontmatter has tag and i need it to have tags whatever shall i do” scenarios. In theory. Hopefully. Please don’t sue me. And if you are going to sue me, at least make backups of your notes before using it so you can have your notes and get a nice windfall from the lawsuit

Given that there is already a panel for showing all properties in all files, renaming, removing and other property management should totally be possible there. That would make intuitive sense and without it properties are just text scattered around in files rather than a solution to metadata management.

6 Likes

Just use Edit → Replace in files. Turn on regex and use something like this:
Find : "\noldproperty: "
Replace : "\nnewproperty: "
Before clicking replace button, you can click on the one of the found files to see what changes are going to be done.

5 Likes

+1 to this feature request. I don’t need it at the moment as I’m not making heavy use of properties - but I could see it being incredibly helpful in the future.

3 Likes

Another +1. This feature would be really, really useful.

3 Likes

+1 we need this feature.

4 Likes

Thank you Leifip.

Yes, the script you provided writes/replaces all files without testing if the property was used or not. (line “with open(file_path, ‘w’) as file:” and th next one)

I have used ChatGPT first to ensure it is possible to modify a file so out of Obsidian…
Its answer is yes :

es, Obsidian typically picks up changes made to the files within your vault, even if you make modifications manually outside of the Obsidian application. Obsidian relies on the file system to detect changes in your vault directory.

When you modify a file, including changing a property name, outside of Obsidian, the next time you launch Obsidian, it should recognize the changes and update its internal representation of the vault accordingly. Obsidian scans the files in your vault directory during startup and loads any new or modified files.

Then I’ve asked it to produce a python script modifying only the relevant files (not tested, I provided it as is)

(The correction point is in the added test “if updated_content != content:”)

import os
import re

def rename_property(file_path, old_property, new_property):
    with open(file_path, 'r', encoding='utf-8') as file:
        content = file.read()

    # Use a regular expression to find and replace the property name
    updated_content = re.sub(fr'(?<=^|\n){old_property}:', f'{new_property}:', content)

    # Check if the content was actually changed
    if updated_content != content:
        # Write the updated content back to the file
        with open(file_path, 'w', encoding='utf-8') as file:
            file.write(updated_content)

def rename_property_in_vault(vault_path, old_property, new_property):
    # Walk through all files in the vault
    for foldername, subfolders, filenames in os.walk(vault_path):
        for filename in filenames:
            if filename.endswith('.md'):  # Process only Markdown files
                file_path = os.path.join(foldername, filename)

                # Check if the property exists in the file before attempting to rename
                with open(file_path, 'r', encoding='utf-8') as file:
                    content = file.read()
                    if re.search(fr'(?<=^|\n){old_property}:', content):
                        rename_property(file_path, old_property, new_property)

if __name__ == "__main__":
    # Replace these values with your actual property names
    old_property_name = "old_property"
    new_property_name = "new_property"

    # Replace this with the path to your Obsidian vault
    obsidian_vault_path = "/path/to/your/obsidian/vault"

    # Rename the property in files that contain the property
    rename_property_in_vault(obsidian_vault_path, old_property_name, new_property_name)

Notice :

Adjust the old_property_name, new_property_name, and obsidian_vault_path variables as needed.

Please note that this script assumes that your properties are formatted as property_name: at the beginning of a line or after a newline character. If your property format is different, you may need to modify the regular expression accordingly. Also, always make a backup of your vault before running scripts that modify multiple files.

1 Like

+1 for me. This would be one of the best QOL features since Properties were created. lol

2 Likes

+1 big time for me!

I don’t even want to think about how much time I’ve spent renaming Properties as my use of the Properties feature evolves. Being able to rename and edit Properties across my entire vault would be SO helpful!!

2 Likes

+1 for me, definitely

I’ve wasted way to much time trying to rename properties in bulk, something like Tag Wrangler would be life changing.

2 Likes

+1. This would be a great addition to Obsidian.

2 Likes

Very good suggestion, I believe many people need these features

2 Likes

More generally I’d like to be able to

  • transform a inline field (type:: source) into a property (and conversely)
  • transform a tag in the note into a tag in tags property
    and because I added a folgezettel in all my note titles (ex: 10.b.3.f- my note), I’d like to move the folgezettel from the title into a property (and conversely) noting that the folgezettel (or any code) is followed by "- "(dash space) so easy to identify.
4 Likes

I am just getting started in setting up my properties and realized that this feature would be extremely useful.

@ryadaj @garryknight @leifjp
As a workaround, one can use bulk find and replace across folder[s] through Notepad++. It is pretty simple and built into Notepad++. This is how I used to rename tags before I found Tag Wrangler.

3 Likes

+1. This is desperately needed!

3 Likes

+1 Would be so helpful!

+1 I also support the idea as it could very time consuming to do it note by note !

Hey, you can check Basic editing > Search across files section of VS Code documentation to learn that, here is a direct link to it: Basic Editing in Visual Studio Code