From 7ffdfa21846e127c1702b3194eaf3b1e10688eeb Mon Sep 17 00:00:00 2001 From: kaotisk Date: Mon, 20 Dec 2021 06:26:15 +0200 Subject: Migration #03 - Converted datetime to epoch format in UTC --- utils/03-migrate_datetime_to_epoch.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 utils/03-migrate_datetime_to_epoch.sh (limited to 'utils') diff --git a/utils/03-migrate_datetime_to_epoch.sh b/utils/03-migrate_datetime_to_epoch.sh new file mode 100755 index 0000000..c5c7312 --- /dev/null +++ b/utils/03-migrate_datetime_to_epoch.sh @@ -0,0 +1,15 @@ +#!/bin/bash +FILES=$(ls -1 news) +for file in $FILES +do + datetime_old=$(echo $file | cut -d '-' -f 1) + date=$(echo $datetime_old | cut -d '_' -f 1) + time=$(echo $datetime_old | cut -d '_' -f 2) + datetime=$(echo $date ${time:0:2}:${time:2:2}:${time:4:2}) + newdatetime=$(date -u -d "${datetime}" +%s) + title=$(echo $file | cut -d '-' -f 2) + newfile=$newdatetime-$title + mv news/$file news/$newfile + git add news/$file news/$newfile + git commit -m "Renamed $file to $newfile according to migration #03" +done -- cgit v1.2.3