You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

15 lines
438 B

#!/bin/sh
set -e
for i in ./*.md; do
if [ "$(basename "$i")" = _index.md ]; then
continue
fi
timestamp=$(grep "^date:" "$i" | cut -d ' ' -f 2 | xargs echo -n)
printf "%s: %s " "$i" "$timestamp"
formatted_date=$(python3 -c "print(__import__('datetime').datetime.strptime('$timestamp', '%Y%m%d%H%M.%S').isoformat())")
printf "%s\n" "$formatted_date"
sed -i'' "s/$timestamp/$formatted_date/" "$i"
done