Autosave: 2024-02-26 17:42:06

This commit is contained in:
thomasabishop 2024-02-26 17:42:06 +00:00
parent d77e5090a4
commit 745963de34

View file

@ -1,16 +1,21 @@
##!/bin/bash ##!/bin/bash
# If there are images in img/ that are not being used by the Zettelkasten, delete them # 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 find "${EOLAS_PATH}/img" -type f | while read filename; do
# Search for the image in the markdown files in the EOLAS_DIR directory # Search for the image in the markdown files in the EOLAS_DIR directory
search_result=$(rg "${filename##*/}" "${EOLAS_PATH}/zk" --type markdown) search_result=$(rg "${filename##*/}" "${EOLAS_PATH}/zk" --type markdown)
# If the image is not found in any file # If the image is not found in any file
if [ -z "$search_result" ]; then if [ -z "$search_result" ]; then
echo "Deleted unused image: ${filename##*/}" unused_images=true
echo "Deleted unused image: ${filename##*/}"
# rm $filename # rm $filename
else
echo "Nothing to purge. All images currently in use."
fi fi
done done
if ! $unused_images; then
echo "Nothing to purge: all images currently in use."
fi