I was trying to display all entries in a folder with a Dataview Table, but sorted by date in Frontmatter. I had it in DD-MM-YYYY, so I couldn’t get it to work and instead I changed all of the files in the folder, here is script in case someone finds it useful. Make sure to backup whatever folder you point this to as this directly changes all files within. Also this assumes the frontmatter is called “Created::” and in the first line of the file. .
#!/bin/bash
DIR="/path/to/folder"
find "$DIR" -type f | while read -r file; do
first_line=$(head -n 1 "$file")
if [[ $first_line =~ ^Created::\ ([0-9]{2})-([0-9]{2})-([0-9]{4})$ ]]; then
day="${BASH_REMATCH[1]}"
month="${BASH_REMATCH[2]}"
year="${BASH_REMATCH[3]}"
new_date="$year-$month-$day"
new_first_line="Created:: $new_date"
sed -i "1s/.*/$new_first_line/" "$file"
echo "Updated file: $file"
else
echo "Skipping file (pattern not matched): $file"
fi
done