Obsidian Metadata
I'm taking an objective-oriented approach and treat every note like an object. Obsidian properties in the frontmatter are the attributes of the object. The type of a note is the class that defines which properties/attributes the note should have (accomplished with the plugin #Metadata Menu).
Commonly used properties
created
: important, because the file system creation and modification dates don't stay consistentupdated
links
: Links to other notestags
: type definition (e.g.#type/project
)class
(used by the plugin Metadata Menu)status
title
: TODO
could be interesting to add:
Project
Type
(duplication of class/tags)
other properties are context-specific, e.g.:
author
url
- β¦
Metadata Menu
The plugin "Metadata Menu" is a key component in my system. It ensures the consistency of my notes.
Docs: https://mdelobelle.github.io/metadatamenu/
Source code: https://github.com/mdelobelle/metadatamenu
Showcase and work-through by Danny Hatcher: YouTube
Editing of properties
Plugin MetaEdit
Edit metadata of the current file via commands
https://github.com/chhoumann/MetaEdit
Plugin Multi-Properties
Add and remove properties to/from multiple files at once.
https://github.com/fez-github/obsidian-multi-properties
DataviewJS
https://forum.obsidian.md/t/update-properties-of-files-from-search-results-in-bulk/72510/
Get files via Dataview query:
const tp = app.plugins.plugins['templater-obsidian'].templater.current_functions_object
const result = await dv.query(`
LIST
WHERE file.folder = this.file.folder
AND file != this.file
`)
if ( result.successful ) {
const values = result.value.values
for (const f of values) {
const tFile = await tp.file.find_tfile(f.path)
await app.fileManager.processFrontMatter(tFile, (fm) => {
console.log(fm, Object.keys(fm).length)
if (Object.keys(fm).length == 0) {
fm['initiallyEmpty'] = true
} else {
if (fm['one']) {
fm['one'] = fm['one'].toUpperCase()
}
delete fm['toBeDeleted']
}
})
}
} else
dv.paragraph("~~~~\n" + result.error + "\n~~~~")
Get files from a specific folder:
const tp = app.plugins.plugins['templater-obsidian'].templater.current_functions_object;
// Get files from a specific folder or directory
const folderPath = "Script try";
const files = app.vault.getMarkdownFiles().filter(file => file.path.startsWith(folderPath));
console.log('Number of files to process:', files.length);
for (const file of files) {
console.log('Processing file:', file.path);
const tFile = await tp.file.find_tfile(file.path);
if (tFile) {
console.log('Found file:', tFile.path);
try {
await app.fileManager.processFrontMatter(tFile, (frontmatter) => {
console.log('Existing frontmatter:', frontmatter);
// Update the 'one' property
frontmatter['one'] = 'second';
console.log('Updated frontmatter:', frontmatter);
});
} catch (error) {
console.error('Error processing frontmatter:', error);
}
} else {
console.log('File not found:', file.path);
}
}
Python script: Obsidian Metadata
Python Skript funktioniert ganz gut, Γ€ndert jedoch die Reihenfolge und teilweise die Syntax
β Nachbesserungen mit anderen Tools/Methoden nΓΆtig
GitHub - natelandau/obsidian-metadata: Batch updates to metadata in an Obsidian vault
Config file: ~/.obsidian_metadata.toml
Transform metadata from inline to frontmatter
Python script: Metadata-changer
Python script: py-obsidianmd
not working well for me
PyPi: py-obsidianmd
GitHub: selimrbd/py-obsidianmd
Docs: py-obsidianmd
cd $wr/notes
python 00_Meta/Scripts/Python/transform_metadata.py
Powershell: Add-MarkdownFrontmatter
see https://forum.obsidian.md/t/add-a-property-to-1-500-files/67793/17
π References
Obsidian Properties: Best Practices and Why? - Knowledge management - Obsidian Forum