Skip to content

Commit 757b5bd

Browse files
authored
Create update_json_date.sh1
1 parent 4d0632f commit 757b5bd

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
3+
# Verzeichnis, das die JSON-Dateien enthält
4+
json_dir="./json/*.json"
5+
6+
current_date=$(date +"%Y-%m-%d")
7+
8+
for json_file in $json_dir; do
9+
if [[ -f "$json_file" ]]; then
10+
current_json_date=$(jq -r '.date_created' "$json_file")
11+
12+
if [[ "$current_json_date" != "$current_date" ]]; then
13+
echo "Updating $json_file with date $current_date"
14+
jq --arg date "$current_date" '.date_created = $date' "$json_file" > temp.json && mv temp.json "$json_file"
15+
16+
git add "$json_file"
17+
git commit -m "Update date_created to $current_date in $json_file"
18+
else
19+
echo "Date in $json_file is already up to date."
20+
fi
21+
fi
22+
done
23+
git push origin HEAD

0 commit comments

Comments
 (0)