Last active
June 20, 2020 16:46
-
-
Save nclv/16c8a07ddf1ab07b40ea82bd135570d0 to your computer and use it in GitHub Desktop.
Publier et renommer les Weeknotes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# publish_weeknote.sh | |
# L'objectif de ce programme est de transférer une weeknote sur le site. | |
# Il faut ajouter le header en format YAML. | |
# Changer le nom du fichier. | |
# Le copier dans le bon répertoire. | |
# Usage : ./publish_weeknotes.sh weeknote post_directory categories | |
# ./publish_weeknote.sh links-ressources/Weeknotes-09.md weeknotes/_posts/ markdown,algorithmique | |
file="$1" | |
fileName="$(basename "$file" .md)" | |
newFileName="$(date +"%Y-%m-%d" -r "$file")-$fileName.md" | |
newFile="$(dirname "$file")/$newFileName" | |
# on ne change pas de directory | |
cp "$file" "$newFile" | |
read -r -d '' header << EOM | |
--- | |
toc: true | |
layout: post | |
categories: [$3] | |
title: $fileName | |
--- | |
EOM | |
echo "$header" | cat - "$newFile" > temp && mv temp "$newFile" | |
mv "$newFile" "$2" | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem Weeknotes-*.md | Rename-Item -newname {$_.LastWriteTime.toString("yyyy-MM-dd-") + $_.Name} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment