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:42:06 +00:00
|
|
|
|
|
|
|
unused_images=false
|
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
|
2024-02-26 17:42:06 +00:00
|
|
|
unused_images=true
|
|
|
|
echo "Deleted unused image: ${filename##*/}"
|
2024-02-25 19:55:06 +00:00
|
|
|
# rm $filename
|
2022-12-27 18:30:05 +00:00
|
|
|
fi
|
|
|
|
done
|
2024-02-26 17:32:51 +00:00
|
|
|
|
2024-02-26 17:46:35 +00:00
|
|
|
if [[ $unused_images == false ]]; then
|
2024-02-26 17:42:06 +00:00
|
|
|
echo "Nothing to purge: all images currently in use."
|
|
|
|
fi
|
|
|
|
|