Monday, August 14, 2023

Cleanup thumbnails in .cache/thumbnails on Kubuntu

touch /home/user/thumbnail_cleanup.sh

#!/bin/bash

THUMBNAILS_DIR="/home/user/.cache/thumbnails/large"
SIZE_LIMIT_MB=100 # Set the size limit in megabytes

while true; do
current_size=$(du -m "$THUMBNAILS_DIR" | cut -f1)
if [ "$current_size" -gt "$SIZE_LIMIT_MB" ]; then
find "$THUMBNAILS_DIR" -type f -mtime +7 -delete
fi
sleep 86400 # Sleep for 24 hours
done

chmod +x /home/user/thumbnail_cleanup.sh // make script executable

touch /home/user/.config/autostart/thumbnail_cleanup.desktop

[Desktop Entry]

Name=large thumbnail cleanup script

Type=Script

Exec=/home/user/thumbnail_cleanup.sh

No comments:

Post a Comment