From dabe96db8c2f35e7ab4c48229211dd9064e22c75 Mon Sep 17 00:00:00 2001 From: Dmitry Ryumin Date: Thu, 8 Feb 2024 21:57:18 +0300 Subject: [PATCH] Update compare_files.sh --- scripts/compare_files.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/compare_files.sh b/scripts/compare_files.sh index 14c9015..15beb8c 100644 --- a/scripts/compare_files.sh +++ b/scripts/compare_files.sh @@ -14,7 +14,14 @@ files_to_update=() if [ -d "$TARGET_DIR" ]; then find "$SOURCE_DIR" -type f -name '*.json' -print0 | while IFS= read -r -d '' file; do relative_path="${file#$SOURCE_DIR/}" - target_file="$TARGET_DIR/$relative_path" + + # Extract the year and the rest of the path + year=$(echo "$relative_path" | awk -F'/' '{print $1}') + + # Remove the year from the relative path + target_file="$TARGET_DIR/${relative_path/${year}\//}" + + echo -e "${target_file} ${year}" if [ -e "$target_file" ]; then # Check if files differ @@ -56,4 +63,4 @@ else for updated_file in "${files_to_update[@]}"; do echo -e "${GREEN}$updated_file${NC}" done -fi +fi \ No newline at end of file