aboutsummaryrefslogtreecommitdiff
path: root/create_notes.sh
diff options
context:
space:
mode:
authorikoamu <ikoamu@gmail.com>2024-01-27 17:18:49 +0900
committerikoamu <ikoamu@gmail.com>2024-01-27 17:18:49 +0900
commitc7c279ca52ab87be6bc2d3042f21f7bbaf4823df (patch)
treeec9de194e8bbd27ccc14634909a468e264c6aa30 /create_notes.sh
parent759b0840cafbf8d6a1f903fae2eb1c3670e2c277 (diff)
Refactor create_notes.sh script to use timestamp-based file matching
Diffstat (limited to 'create_notes.sh')
-rwxr-xr-xcreate_notes.sh20
1 files changed, 9 insertions, 11 deletions
diff --git a/create_notes.sh b/create_notes.sh
index cf1112e..1760018 100755
--- a/create_notes.sh
+++ b/create_notes.sh
@@ -1,22 +1,20 @@
#!/bin/bash
-orgPath=$1
+org_path=$1
mkdir -p notes
-# cat graphdata.json
-
-ls -ls "${orgPath}"
-
cat graphdata.json |
jq -c '.data.nodes[]' |
while read -r nodes; do
id=$(echo "${nodes}" | jq -r '.id')
file=$(echo "${nodes}" | jq -r '.file')
echo "============================="
- echo "id: ${id}"
- echo "file: ${file}"
- cat "${orgPath}/${file}"
-
- cp -p "${orgPath}/${file}" "notes/${id}"
-done \ No newline at end of file
+
+ timestamp=$(echo "${file}" | cut -d'-' -f1)
+ matching_file=$(find "${org_path}" -name "${timestamp}-*.org" -type f)
+
+ if [[ -f "${matching_file}" ]]; then
+ cp -p "${matching_file}" "notes/${id}"
+ fi
+done