Skip to content

Instantly share code, notes, and snippets.

@pichfl
Created March 28, 2012 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pichfl/2226461 to your computer and use it in GitHub Desktop.
Save pichfl/2226461 to your computer and use it in GitHub Desktop.
A quick and dirty bash file that converts a folder full of YYYY-MM-DD-*name*.markdown into folders with textfiles for use with Kirby CMS
#!/bin/bash
cd /folder/with/your/posts
COUNTER=1
for filename in *
do
echo "----" >> $filename
echo "Date: ${filename:0:10}" >> $filename
echo "----" >> $filename
newfilename=${filename:11}
newfilename=${newfilename%.markdown}
foldername=$COUNTER-$newfilename
COUNTER=$(($COUNTER + 1))
mkdir $foldername
mv $filename $foldername/post.txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment