From 745963de345ef6c40eaefeb56f70ec9648b7e381 Mon Sep 17 00:00:00 2001 From: thomasabishop Date: Mon, 26 Feb 2024 17:42:06 +0000 Subject: [PATCH] Autosave: 2024-02-26 17:42:06 --- scripts/purge_images.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/purge_images.sh b/scripts/purge_images.sh index 3dd0fd5..13575fd 100755 --- a/scripts/purge_images.sh +++ b/scripts/purge_images.sh @@ -1,16 +1,21 @@ ##!/bin/bash # If there are images in img/ that are not being used by the Zettelkasten, delete them + +unused_images=false find "${EOLAS_PATH}/img" -type f | while read filename; do # Search for the image in the markdown files in the EOLAS_DIR directory search_result=$(rg "${filename##*/}" "${EOLAS_PATH}/zk" --type markdown) # If the image is not found in any file if [ -z "$search_result" ]; then - echo "Deleted unused image: ${filename##*/}" + unused_images=true + echo "Deleted unused image: ${filename##*/}" # rm $filename - else - echo "Nothing to purge. All images currently in use." fi done +if ! $unused_images; then + echo "Nothing to purge: all images currently in use." +fi +