aboutsummaryrefslogtreecommitdiff
path: root/blogarticledate
diff options
context:
space:
mode:
Diffstat (limited to 'blogarticledate')
-rwxr-xr-xblogarticledate17
1 files changed, 9 insertions, 8 deletions
diff --git a/blogarticledate b/blogarticledate
index 888f06a..6eb73a1 100755
--- a/blogarticledate
+++ b/blogarticledate
@@ -1,16 +1,17 @@
-#!/bin/sh
+#!/usr/bin/env bash
# resets blog articles file date to the date indicated
# in the article
+postDir=/home/philip/web/articles/2025
-postArray=( $(ls *.html) )
+mapfile -t postArray < <(ls -t "$postDir"/*.html)
for posts in "${postArray[@]}"; do
- post=$posts
- postdate=$(grep -o '>.*</h5>' $post | sed 's/\(>\|<\/h5>\)//g')
- echo $postdate
+ post="$posts"
+ postdate=$(grep -o '>.*</h5>' "$post" | sed 's/\(>\|<\/h5>\)//g')
+ echo "$postdate"
#[[CC]YY]MMDDhhmm[.ss]
postdate="${postdate//-}0000"
- echo Date=$postdate
- echo Item=$post
- touch -a -m -t $postdate $post
+ echo Date="$postdate"
+ echo Item="$post"
+ touch -a -m -t "$postdate" "$post"
done