htg-content/rename_posts.sh

12 lines
309 B
Bash
Raw Normal View History

2020-05-13 09:46:58 +02:00
#!/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'`
2020-05-13 09:50:49 +02:00
mv -v $post $safename.md 2> /dev/null
2020-05-13 09:46:58 +02:00
done