Create sequential IDs for notes (in metadata)

What I’m trying to do

I’m using Obsidian as my Zettelkasten. When I create a note, I would like it to be assigned a unique ID using a sequential numbering format (0001, 0002, 0003, …) and store that as the id in the note’s metadata/frontmatter. I plan on referencing the note ID in external systems, including analog notebooks, so it’s important that the ID be short (6 characters or less).

Ex: D00146 (Digital notebook, Note # 146)

I’ll likely want to store this ID in the notes metadata

---
id: D00146
---

What’s the simplest way to automate this?