From 5947ace2e4fd3663a75da3deea321b1cae951ef4 Mon Sep 17 00:00:00 2001 From: raspbeguy Date: Wed, 13 May 2020 09:46:58 +0200 Subject: [PATCH] add renaming script --- rename_posts.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 rename_posts.sh diff --git a/rename_posts.sh b/rename_posts.sh new file mode 100755 index 0000000..90f74df --- /dev/null +++ b/rename_posts.sh @@ -0,0 +1,11 @@ +#!/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