#!/bin/bash
# /usr/local/bin/largest_images
# http://crystalfaeries.net/posix/bin/largest_images
# celeste:crystalfaery 2016-08-04 18:41:49+00:00
# Review images by decreasing file size but display whole containing folders
# continue with existing non-zero, or create new list of images (see /usr/local/bin/find_images)
if [ -s ~/.imgs.txt ]
then
touch ~/.imgs.txt # kilroy was here
else
echo finding_images... >&2
find / \( \( -path /media/ -prune \) -o \( -path $HOME/tails/ -prune \) -o \( -path /var/cache/rsnapshot/ -prune \) -o \( -path /home/rsnapshot/ -prune \) -o \( -iname '*.gif' -exec du {} \; \) -o \( -iname '*.jpeg' -exec du {} \; \) -o \( -iname '*.jpg' -exec du {} \; \) -o \( -iname '*.png' -exec du {} \; \) -o \( -iname '*.pnm' -exec du {} \; \) -o \( -iname '*.svg' -exec du {} \; \) \) 2> /dev/null | sort -rn | cut -f2- | grep -v /home/`whoami`/.local/share/Trash > ~/.imgs.txt # the size sorted list of image files
fi
# review listed image directories
while [ -s ~/.imgs.txt ]
do
d=$(dirname $(head -n 1 ~/.imgs.txt))
grep -v "$d" ~/.imgs.txt > /tmp/$$.imgs.txt
mv /tmp/$$.imgs.txt \
~/.imgs.txt
if [ -d "$d" ]
then
echo "viewing: $d" >&2 # log the directory
gwenview "$d" # view the directory
echo "viewed : $d" >&2 # log the directory
fi
done
syntax highlighted by Code2HTML, v. 0.9.1