Last active
November 17, 2022 15:52
-
-
Save eallion/afdbd8bf7f929a381a95cd8a6adca894 to your computer and use it in GitHub Desktop.
rename hugo post filenem format date+slug with front matter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# extracts date from file in the format | |
# date: 2013-08-23 14:52:59 | |
# and prepends this to the filename | |
for f in *.md; do | |
c="$(grep -Eo 'date:\W\"(....-..-..)' $f | cut -d'"' -f2 | xargs)" | |
s="$(grep -Eo 'slug:\W\"(.+)' $f | cut -d'"' -f2 | xargs)" | |
mv "$f" "$c-$s.md" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment