Skip to content

BonfireAtNight/rename_markdown_files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

rename_markdown_files

Rename Markdown files in accordance with the title of the document.

Installation

The script doesn't need to be installed, just download and execute it. However, since you'll need to have Python installed. For ease of use it's convenient to put the script into a directory known to the PATH variable (like ~/.bin).

Usage

rename_markdown_files.py [FILE]... [OPTIONS]...
  • -l: replace uppercase letters in the title by lowercase letters in the file name
  • -o: allow only letters, the underscore (_), and the hypthen (-) in the file name
  • -u or -y: replace spaces by underscores or hyphens
  • -h: help

Motivation

Markdown files have a name and (usually) a title (H1). In Obsidian, the two are used for different purposes. Today, the file names primarily serves as unique identifier. In the past, it had been used in other contexts for which Obsidian now uses titles.

Among the different possibilities to handle file name and title, many users prefer to keep them in sync. There is an Obsidian community plugin, obsidian-filename-heading-sync, that automatically renames title and file if the respective other changes. The plugin cannot well be used to adhere to certain file-naming standards.

Users are often adviced to avoid spaces in their file names and to replace them by either the underscore (_) or the hyphen (-). More rigorous conventions recommend to replace uppercase letters with lowercase letters and to avoid all symbols other than letters, the underscore, and the hyphen.

The above-explained options account for these different conventions. Umlaute and certain symbols disallowed by Obsidian are removed without giving the option to keep them.

Examples

# Dies ist ein Titel / eine Überschrift!
Einige wichtige Informationen
rename_obsidian_files.py ~/Notes/test.md
# New file name: Dies ist ein Titel  eine Ueberschrift!.md

rename_obsidian_files.py ~/Notes/test.md -u
# New file name: Dies_ist_ein_Titel__eine_Ueberschrift!.md

rename_obsidian_files.py ~/Notes/test.md -ylo
# New file name: dies-ist-ein-titel--eine-ueberschrift.md

# Rename all files in the current directory
rename_obsidian_files.py *

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages