Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save andredtr/42de65ff05a0a02f6ebfa26ad1841f7e to your computer and use it in GitHub Desktop.

Select an option

Save andredtr/42de65ff05a0a02f6ebfa26ad1841f7e to your computer and use it in GitHub Desktop.
#!/bin/bash
# usefull when importing notes from Notion.
# Update the creation date of each .md file
for file in *.md; do
created=$(grep "Created" "$file") # created="Created: January 20, 2020 8:16 PM"
# extract the date from the string
date=${created#*: } # date="January 20, 2020 8:16 PM"
# convert the date to a format that touch can understand
formatted_date=$(date -j -f "%B %d, %Y %I:%M %p" "$date" "+%Y%m%d%H%M.%S")
echo "$file: $formatted_date"
touch -t "$formatted_date" "$file"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment