20 lines
437 B
Bash
Executable File
20 lines
437 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ -f config.sh ]; then
|
|
. config.sh
|
|
fi
|
|
|
|
if [ -z "$POSTS_DIR" ]
|
|
then
|
|
echo "POSTS_DIR environment variable is unset." > /dev/stderr
|
|
exit 2
|
|
fi
|
|
|
|
cd $POSTS_DIR
|
|
for post in *
|
|
do
|
|
title=`sed -n 's/^title: "\?\(.*\)"\?$/\1/p' $post`
|
|
safename=`echo $title | iconv -t ascii//TRANSLIT | tr '[:upper:]' '[:lower:]' | tr -s '[:punct:] ' '-' | sed 's/-*$//g;s/^-*//g'`
|
|
mv -v $post $safename.md 2> /dev/null
|
|
done
|