Script to Identify Notes with Metadata Format Issues

Hello everyone,
I have a series of notes within a specific folder, and I suspect that some of the metadata might have an incorrect format. When this happens, and I try to run a query, the note in question doesn’t show up.
I’d like to create a small script to help me identify notes with this issue so I can fix them.
Could anyone provide some support?

Below is one example : slight_smile:

Best regards.

No script needed. This is rather easily fixed.

Click on the customer_cod property icon and set it to text type as it is currently set to number. You cannot have text strings mixed with numbers on a number type property.

Following this action, the types.json file in your config folder will be updated and consequently all files with this property will be handled properly.

The link below might be of some help:

Thank you for the response.
Actually, I’m not looking to correct the error, as I already know the procedure. Instead, I’d like to identify, among 1,000 notes, those with a metadata format issue so that I can fix them.

best regards

Hampton, could you finish the DataviewJS source code you sketched out so I can test if it works?
Unfortunately, I couldn’t quite grasp your hint, as I’m not very strong in programming.

Best regards

1 Like

I don’t know any DataviewJS coding but thought the post might be a starting point for you. Hope someone can help.

Okay, I understand what you’re trying to achieve. You want a query to draw your attention to what needs fixing.
You want to feel secure that your queries don’t miss any files.

In the linked post, the creator also points out you need to manually check what error your particular lines may have.

In this thread people also created some code to help them with finding inconsistencies and problems in their vaults.
None of those snippets relate to your case.
You see, you need to know about the types of problems that may arise and then query for them.
So you need to go through properties and then have scripts written (ChatGPT 4o can write DVJs fairly well) based on what faults you expect.

What I said in my first post I will repeat now: when you change to the proper property type, all files with that property will be fixed, not just the one file you have seen the error.
I recommend opening All Properties and open files clicking on properties to perform random manual visual checks.

Once you know what type errors you are making, you will know how to query for them with the regular expressions you either need to learn (will come handy in the future too) or you need to learn how to prompt a bot to get a good regex out of them.

I also have many queries that point me in the direction of faulty files (not to do with properties though), but in order to have my scripts written (after a while you can re-use scripts and just change some regex in them so faster than re-prompting bots with much the same thing), I had to understand the problem and how to query with the right regex for them first.

When you use Obsidian, the volume of manual upkeep is proportional to your skill level: the less skill, the more repetitive time-consuming fiddling, clicking, etc. So I understand you want to cut down on this time cutting into your work.
But it’s your vault (“body”), it’s you who enters info in it (I don’t like AI write any of my notes for this reason), so you will need to understand about the typical “ailments” in it and find the best course of action to find remedies.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.