eolas/scripts/purge_images.sh

17 lines
559 B
Bash
Raw Normal View History

2024-02-26 17:32:51 +00:00
##!/bin/bash
2022-12-27 18:30:05 +00:00
2024-02-25 19:38:14 +00:00
# If there are images in img/ that are not being used by the Zettelkasten, delete them
2024-02-26 17:32:51 +00:00
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
2022-12-27 18:30:05 +00:00
echo "Deleted unused image: ${filename##*/}"
2024-02-25 19:55:06 +00:00
# rm $filename
2024-02-26 17:32:51 +00:00
else
echo "Nothing to purge. All images currently in use."
2022-12-27 18:30:05 +00:00
fi
done
2024-02-26 17:32:51 +00:00