Roam import: Regex for modifying file names of Daily Notes?

For the latest instructions see the official Roam Research import guide


I would like to import my notes from Roam. And I would like to rename the file names of my Daily Notes from Roam’s format (September 18th, 2020.md) to something numeric like 2020-09-18.md. As far as I can tell, Obsidian’s built-in import formatter doesn’t do this yet, and the “Daily notes” plugin doesn’t reformat existing note titles, so it seems that my best bet would be to use software like Bulk Rename Utility combined with regex. However, I’m a regex beginner. So, I thought I would check: has anyone already solved this? Thanks!

Hmm, well this has been requested.

https://forum.obsidian.md/t/allow-changing-roam-date-format-when-doing-markdown-import/446

I haven’t done this myself, but some initial ideas would be to target files that end with , 2020.md. From there, I think you’ll need a script to convert the date format. Do you have any programming experience?

Here’s an Obsidian user that walks you through scripting this in python: https://www.youtube.com/watch?v=9sjDiBbt9Zc&feature=youtu.be

1 Like

Awesome! Many thanks. That was enough to get me started. The script linked to from the youtube video helped me construct a workable regular expression. (Writing my own script would be preferable but a lot harder for me.) Anyway, at least I can now avoid renaming every file manually and instead just run 24 operations (2 per month).

For example, for September single-digit days, the regular expression (using Bulk Rename Utility) would be September\s(\d{1})\w{1,2},\s(\d{4}), and the replacement string would be \2-09-0\1. For double-digit days, the regular expression would be September\s(\d{2})\w{1,2},\s(\d{4}), and the replacement string would be \2-09-\1.

Eventually, it would be great to put together a script (perhaps using Python’s dateutil parser, as in the linked script), or perhaps a corresponding feature will be added to Obsidian, but this semi-automated Regex approach works for me for now. (Perhaps there’s also a way to create a single search and replace combo that works for both single- and double-digit dates…)

1 Like

The script mentioned in the youtube video has two drawbacks:

  • Did not ignore files in .git, .obsidian, etc.
  • Did not change file names

I added forked the code here and fast fixed that with filtering files ending with .md and modify the file names also.

Anyone wanna make the code better (e.g., directly filter .git) feel free to fork.

1 Like

I wanted to change the dates to YYYYMMDD (without the -) but cannot figure out how to tweak your script… Would you mind shedding some light? Thanks.

1 Like

Me too!! @Joilence , your help would be highly appreciated!