From c7c279ca52ab87be6bc2d3042f21f7bbaf4823df Mon Sep 17 00:00:00 2001 From: ikoamu Date: Sat, 27 Jan 2024 17:18:49 +0900 Subject: [PATCH] Refactor create_notes.sh script to use timestamp-based file matching --- create_notes.sh | 20 +++++++++----------- 1 file 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