# Converting Roam Daily Notes To YYYY-MM-DD format, with backlinks

**URL:** <https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770>\
**Category:** Workflows & Templates\
**Created:** [February 27, 2021, 6:08pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770 "2021-02-27T18:08:01Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [February 27, 2021, 6:08pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/1 "2021-02-27T18:08:01Z")

</div>

For the latest instructions see the [official Roam Research import guide](https://help.obsidian.md/import/roam)

> **[Import from Roam Research - Obsidian Help](https://obsidian.md/help/import/roam)**
>
> Import from Roam Research - Obsidian Help

* * *

This is a small bash script I used to convert Roam Daily notes so they work with a YYYY-MM-DD format and add some front matter metadata to work better in Obsidian.

#### Note for MacOS Users

`bash` `sed` and `date` in this script assume a GNU userland. If you are on Linux it should just work. If you are on Mac OS X try `brew install bash gnu-sed gnutls` and make sure gnu `sed` `date` and `bash` are on your path.

```bash
export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH
export PATH=/usr/local/opt/gnu-sed/libexec/gnubin:$PATH

```

I’ve not tried it with Mac OS X’s BSD version of these.

## Usage

**As always, backup before trying this.**

Note if you’ve seeded an Obsidian vault with a Roam Research markdown export, make sure to close that vault before running this script. Obsidian observes changes in the vault folder and tries to update its indexes during the conversion which will slow things down.

From the root of a Roam Research markdown export run:

```auto
# convert all daily notes from 2020/2021
ls *,\ 202[01].md | convert_daily_notes

```

## `convert_daily_notes` Script

```bash
#/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

roam_date_to_obsidian() {
  date --date="$(echo "${*}" | sed 's/th//;s/nd//;s/rd//;s/1st/1/')" \
    '+%Y-%m-%d'
}

while IFS= read -r line; do
  roam_daily_note=${line/%.md/}
  obsidian_daily_note=$(roam_date_to_obsidian ${roam_daily_note})

  # add front matter
  echo "---" >> ${obsidian_daily_note}.md
  echo "tags: [daily]" >> ${obsidian_daily_note}.md
  echo "---" >> ${obsidian_daily_note}.md

  cat "${roam_daily_note}.md" >> ${obsidian_daily_note}.md

  # update links
  sed -i "s/\[\[${roam_daily_note}]]/[[${obsidian_daily_note}]]/g" *.md */*.md || true

  # give it a relevant timestamp
  touch -d ${obsidian_daily_note} ${obsidian_daily_note}.md

  rm "${roam_daily_note}.md"
done

```

## Related

> [@Get all uploaded files in Roam Research to Obsidian](https://forum.obsidian.md/t/get-all-uploaded-files-in-roam-research-to-obsidian/13573/2):
>
> You can try these two commands or modify them to your use (run from your vault root). I recommend making a backup first or managing the vault with git. First, download a markdown export of all your notes and extract the zip file. The commands below can be run in that extracted folder. Download all images off firebase and store them in \_attachment/img. mkdir -p \_attachment/img && \ sed -n 's/.\*\[](\(https:\/\/firebasestorage.\*\)).\*/\1/gp' \*.md \*/\*.md \ | sort | uniq \ | sed 's/.\*%2F…

---

<div class="post-metadata">

**Author:** ![jimw](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jimw](https://forum.obsidian.md/u/jimw)\
**Post date:** [April 16, 2021, 7:32pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/2 "2021-04-16T19:32:09Z")

</div>

Hi,

A complete newbie to both Obsidian and Bash scripts… I’m using Windows 10, could you please point me in the right direction of how to put this together?

Can I simply cut and paste the code into Notepad and he invoke it from Command Prompt?!

Really sorry for the simplicity of this question - this solution looks perfect for my needs!!

Thanks

Jim

---

<div class="post-metadata">

**Author:** ![jimw](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jimw](https://forum.obsidian.md/u/jimw)\
**Post date:** [April 16, 2021, 8:38pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/3 "2021-04-16T20:38:38Z")

</div>

OK - so I’ve made some headway with this (thanks to Google!)

I’ve installed Ubuntu from the Windows store and have created the “convert\_daily\_notes.sh” file within the relevant vault using the nano editor.  
I have then tried various versions to try and run the script:

1. As above
2. ./ convert\_daily\_notes.sh

But I’ve had the following error returned  
cat: .md: No such file or directory

or  
convert\_daily\_notes: command not found

Where am I going wrong!!!

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [April 17, 2021, 2:18am UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/4 "2021-04-17T02:18:58Z")

</div>

I’m impressed (I don’t have windows).  
Sounds like you have an ubuntu user environment. Great. Make sure you are using a bash shell (type “echo $SHELL”)

If you’ve downloaded your file and named it convert\_daily\_notes.sh, that’s okay. Try typing this at your command prompt from inside the folder where you have the script:

```bash
chmod 755 convert_daily_notes.sh

```

that will make the script executable  
then try running just the ls command from your vault and see what you get

```bash
ls *,\ 202[01].md

```

if everything is working, it should list all your daily notes from 2020 and 2021, assuming they are also all in the vault root as they would be after making a roam markdown export.

Finally try running the full command

```bash

ls *,\ 202[01].md | ./convert_daily_notes.sh

```

(assuming your convert script is also in the vault root)

remember to close obsidian before running that; it could take awhile

---

<div class="post-metadata">

**Author:** ![jimw](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jimw](https://forum.obsidian.md/u/jimw)\
**Post date:** [April 17, 2021, 8:34am UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/5 "2021-04-17T08:34:13Z")

</div>

Thank you!! The results are mixed!!

> chmod 755 convert\_daily\_notes.sh

Returns “chmod: changing permission of ‘convert\_daily\_notes.sh’: Operation not permitted”

> ls \*,\ 202[01].md

Works as expected and lists everything

> ls \*,\ 202[01].md | ./convert\_daily\_notes.sh

Then returns “./convert\_daily\_notes.shL line 15: 2020-04-12.md: Permission denied”  
I’m not sure whether this is related to the lack of permission earlier or whether there is something specific to this file (there is no file called “2020-04-12.md”, but there is “April 12th, 2020.md”)?

Really appreciate your help - thank you

---

<div class="post-metadata">

**Author:** ![jimw](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jimw](https://forum.obsidian.md/u/jimw)\
**Post date:** [April 17, 2021, 8:40am UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/6 "2021-04-17T08:40:29Z")

</div>

OK, I’ve tested a bit more:

- The folder is in OneDrive, so I’ve turned off sync
- I’ve checked all instances of Obsidian are closed (and exited)
- I’ve moved the “April 12th, 2020” out of the vault and now have the following:

> sed: preserving permissions for ‘./sedLc9028’: Operation not permitted  
> sed: cannot rename ./sedLc9028’: Permission denied  
> touch: setting times of ‘2020-04-13.md’: Operation not permitted

---

<div class="post-metadata">

**Author:** ![jimw](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@jimw](https://forum.obsidian.md/u/jimw)\
**Post date:** [April 18, 2021, 9:27am UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/7 "2021-04-18T09:27:48Z")

</div>

This was completely right!!! The problem was OneDrive (as it always is!) - I needed to make sure that the folder was “Always available on this device”!

100% converted - thank you SO much pmbauer - I’ll write more complete notes on how I did this for future Windows users later in the week

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [April 18, 2021, 7:54pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/9 "2021-04-18T19:54:49Z")

</div>

I am happy to add any tips you have to make it work in a windows section of the parent post. Great work getting this to run on windows!

---

<div class="post-metadata">

**Author:** ![friednslip](https://forum.obsidian.md/user_avatar/forum.obsidian.md/friednslip/32/9603_2.png) [@friednslip](https://forum.obsidian.md/u/friednslip)\
**Post date:** [April 27, 2021, 10:13am UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/10 "2021-04-27T10:13:05Z")

</div>

Hi @pmbauer — this is exactly what I was hoping to find. alas i’m on Mac OS X and don’t speak bash— so I understand that you won’t be able to replicate exactly— but maybe there’s a small chance:

1. I replaced sed with gsed and saved the script on the roam markdown export folder —which I’ve renamed as roam

2. ran chmod 755 convert\_daily\_notes.sh and the test ls command — which worked

3. however, when I ran ls \*,\ 202[01].md | ./convert\_daily\_notes.sh— the response I got was

Any chance you might know what happened here/ how I might be able to fix it?

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [April 27, 2021, 2:23pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/11 "2021-04-27T14:23:34Z")

</div>

from your prompt, what does `which date` say? it probably needs to point to a symlink to someplace in the brew packages (needs to be gnu date). if it’s /usr/bin/date, probably still using the bsd date utility.

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [April 27, 2021, 2:36pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/12 "2021-04-27T14:36:51Z")

</div>

hey, I’m pretty sure this is it. Before running the script, try running this:

```auto
export PATH=/usr/local/opt/coreutils/libexec/gnubin:$PATH

```

Or update the script to use `/usr/local/opt/coreutils/libexec/gnubin/date`

---

<div class="post-metadata">

**Author:** ![obsidvicious](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/o/8e8cbc/32.png) [@obsidvicious](https://forum.obsidian.md/u/obsidvicious)\
**Post date:** [August 4, 2021, 7:19pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/14 "2021-08-04T19:19:58Z")

</div>

> [@jimw](#):
>
> I’ll write more complete notes on how I did this for future Windows users later in the week

Hey, any update on that step-by-step Windows conversion guide? Would love to be able to convert these daily note pages with links intact. (And daily more annoyed that Roam devs thought this naming convention would be a good idea in the first place)

---

<div class="post-metadata">

**Author:** ![pmbauer](https://forum.obsidian.md/user_avatar/forum.obsidian.md/pmbauer/32/10201_2.png) [@pmbauer](https://forum.obsidian.md/u/pmbauer)\
**Post date:** [August 4, 2021, 8:48pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/15 "2021-08-04T20:48:50Z")

</div>

I believe @jimw 's issues were due to onedrive not having all the files downloaded.  
The script should just work if you

> I’ve installed Ubuntu from the Windows store and have created the “convert\_daily\_notes.sh” file within the relevant vault using the nano editor.

So if you install the Windows Subsystem for Linux the script should just work in that environment. You can ignore the MacOS X instructions. (I don’t have a windows install handy to confirm this).

---

<div class="post-metadata">

**Author:** ![TheAOR](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/t/a87d85/32.png) [@TheAOR](https://forum.obsidian.md/u/TheAOR)\
**Post date:** [November 11, 2021, 4:29pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/16 "2021-11-11T16:29:14Z")

</div>

Lets say I’m a year in to using Obsidian and have already used this script successfully to convert everything during my initial migration from Roam, but continued using the “MMMM Do, Y” format for my Daily Notes (and their file names). Realizing now that I should’ve stuck with the YYYY-MM-DD format due to the majority of plugins I use referencing the YYYY-MM-DD format.

Could I technically run this convert all of my dates, file names, (and any date shown on any note using “MMMM Do, Y” to “YYYY-MM-DD” format?

---

<div class="post-metadata">

**Author:** ![MagnusHultin](https://forum.obsidian.md/user_avatar/forum.obsidian.md/magnushultin/32/40702_2.png) [@MagnusHultin](https://forum.obsidian.md/u/MagnusHultin)\
**Post date:** [January 2, 2023, 5:47pm UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/17 "2023-01-02T17:47:19Z")

</div>

I use MacOS 13.1 and followed the instructions to brew install bash gnu-sed gnutls. I kept running into issues when setting the environment, but managed to get it up and running by specifying gdate, gsed and gtouch in the code.

````auto
#/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

roam_date_to_obsidian() {
  gdate --date="$(echo "${*}" | gsed 's/th//;s/nd//;s/rd//;s/1st/1/')" \
    '+%Y-%m-%d'
}

while IFS= read -r line; do
  roam_daily_note=${line/%.md/}
  obsidian_daily_note=$(roam_date_to_obsidian ${roam_daily_note})

  # add front matter
  echo "---" >> ${obsidian_daily_note}.md
  echo "tags: [daily]" >> ${obsidian_daily_note}.md
  echo "---" >> ${obsidian_daily_note}.md

  cat "${roam_daily_note}.md" >> ${obsidian_daily_note}.md

  # update links
  gsed -i "s/\[\[${roam_daily_note}]]/[[${obsidian_daily_note}]]/g" *.md */*.md || true

  # give it a relevant timestamp
  gtouch -d ${obsidian_daily_note} ${obsidian_daily_note}.md

  rm "${roam_daily_note}.md"
done```

Just in case it helps someone else.
````

---

<div class="post-metadata">

**Author:** ![claytonman](https://forum.obsidian.md/user_avatar/forum.obsidian.md/claytonman/32/84639_2.png) [@claytonman](https://forum.obsidian.md/u/claytonman)\
**Post date:** [March 12, 2025, 1:36am UTC](https://forum.obsidian.md/t/converting-roam-daily-notes-to-yyyy-mm-dd-format-with-backlinks/13770/19 "2025-03-12T01:36:55Z")

</div>

Your approach is neat - doing this conversion in Road Research vault rather than Obsidian vault. Thanks for sharing!

For me I would need a slightly different approach, as I already migrated from Roam Research to Obsidian a few years ago. I have a few thousand legacy daily note files from Roam that follow the annoying month-day-year format, and a few thousand daily notes from Obsidian that follow YYYY-MM-DD format.

This shell script served me well. At least I could rename all the legacy daily note files into a uniform YYYY-MM-DD.md convention, though the links inside those old notes remain unchanged.

duh… this forum doesn’t allow link. That’s a bummer. Well, my shell script can be found on my site, digitalsovereignty.herbertyang.xyz
