Skip to content

Instantly share code, notes, and snippets.

@ear1grey
Created July 21, 2015 08:36
Show Gist options
  • Save ear1grey/c73764762b0f52bb0d98 to your computer and use it in GitHub Desktop.
Save ear1grey/c73764762b0f52bb0d98 to your computer and use it in GitHub Desktop.
Front Matter Move: Rename files in a folder based on the date contained in jekyll/markdown frontmatter
#!/bin/sh
# extracts date from file in the format
# date: 2013-08-23 14:52:59
# and prepends this to the filename
for f in *.md; do
c="$(grep -Eo 'date:\W(....-..-..)' $f | cut -d: -f2 | xargs)"
mv "$f" "$c-$f"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment