Created
November 7, 2015 22:30
-
-
Save KevinGimbel/9598b24728418d8f287c to your computer and use it in GitHub Desktop.
A bash script to convert Markdown files from Jekyll-like Format to Metalsmith Format.
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
###################################################################### | |
# convert_posts # | |
# # | |
# A bash script to convert Jekyll-style files into Handlebar files. # | |
# # | |
# Reads the current directory, searches for all *.md files and # | |
# then replaces the first line with # | |
# --- # | |
# date: $DATE # | |
# # | |
# DATE is the date taken from the file name which starts # | |
# with YYYY-MM-DD for Jekyll sites. # | |
# # | |
# Optional the script can also remove the YYYY-MM-DD- prefix, just # | |
# pass anything as argument like convert_posts true # | |
###################################################################### | |
for file in *.md | |
do | |
DATE=$(echo $file | cut -c1-10) | |
FILENAME=$(echo $file | cut -c12-100) | |
sed -i "1s/.*/---\ndate: $DATE/" $file | |
if [ ! -z "$1" -a "$1" != " " ]; then | |
mv $file $(echo $FILENAME) | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment