30 lines
763 B
Bash
Executable File
30 lines
763 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
extension=".blog"
|
|
srcdir="src"
|
|
dbdir="db"
|
|
default_author="olivier"
|
|
default_tag="import"
|
|
|
|
for i in `ls *${extension}`
|
|
do
|
|
# fetch data
|
|
datetime=`basename $i ${extension}`
|
|
dY=${datetime:0:4}
|
|
dm=${datetime:4:2}
|
|
dd=${datetime:6:2}
|
|
dH=${datetime:8:2}
|
|
dM=${datetime:10:2}
|
|
dS=${datetime:12:2}
|
|
date=`date -d "${dY}-${dm}-${dd} ${dH}:${dM}:${dS}" +'%s'`
|
|
title=`cat $i|head -n 1|sed -e 's#/##g'`
|
|
content=`cat $i|sed '1d'`
|
|
# write result
|
|
echo -e "TITLE = ${title}\nAUTHOR = ${default_author}\nTAGS = ${default_author}" > "${dbdir}/${date},${title}.mk"
|
|
echo ${content} > "${srcdir}/${title}.md"
|
|
# Display a point so that user can see we have finished something (useless)
|
|
echo -n '.'
|
|
done
|
|
# Implicit Carriage return
|
|
echo ""
|