add renaming script

This commit is contained in:
raspbeguy 2020-05-13 09:46:58 +02:00
parent 393a4889b6
commit 5947ace2e4
1 changed files with 11 additions and 0 deletions

11
rename_posts.sh Executable file
View File

@ -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