So I have a directory with lots of .md
files that look like this:
file-something-name.md
3330-file-another-name.md
a-yet-another-file-name.md
Inside each .md file is info that looks like this (the values are different but keys are same for each file):
---
title: “Something title”
date: "2020-05-08"
category: something
---
Some markdown text here.
Now, what I want to do is, loop through ALL the .md
files and add inside each file a new line after the date
key line, with this info:
slug: “/[NAME-OF-MD-FILE]/“
so the new file after the change will look like this:
---
title: “Something title”
date: "2020-05-08"
slug: “/file-something-name/“
category: something
---
There is one more thing - if the “slug” line already exists, it should skip that file and dont change anything as some files might have slug
key already in their front matter.
I will PayPal you 20USD for this quick bash script. Comment in this topic you are interested and send me DM.