htg-content/rename_posts.sh

12 lines
293 B
Bash
Executable File

#!/bin/bash
POSTS_DIR="content/posts"
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 $post $safename.md
done