cleanthumbs.py

cleanthumbs logo

The most current version is 1.0, released 2010-04-16.

Motivation

The GNOME desktop caches thumbnails of images in a directory hierarchy in $HOME/.thumbnails. However, if the original image is deleted, the thumbnail remains in the cache directory. This can lead to a massive waste of a lot of disk space:
$ du -sm ~/.thumbnails
506 ~/.thumbnails

The thumbnails contain the original location of the image they were created from in the comment block. cleanthumbs.py retrieves the location of the original image from all thumbnails and checks for its existance. If the original image is not found, the thumbnail is deleted.

To see what would happen, you may want to do a trial run first:
$ cleanthumbs.py -v --dry-run

View the source.

Requirements

  • python programming language
    (should already be installed on any computer runnng the GNOME desktop)
  • PIL - Python Image Library PIL Homepage
    on the commandline try: $ python -c "import Image"
    Unless you get an error, PIL is already installed on your system.
    If you get an error you may first try to install PIL via the package manager of your system.
    systempackage name
    FreeBSDpy26-imaging
    RedHat/Fedorapython-imaging
    Ubuntupython-imaging

Download

The software is licensed under a BSD style license. See license.txt.

Commandline Options

  --always-remove=PATH always remove thumbnails of local images whose location starts with PATH. Be sure to add a trailing "/" if you want a directory.
May be specified more than once.
Eg. --always-remove=/media/cdrom/
-h --help display help message
-k --keep-nonlocal don't delete thumbnails that are not associated with local files (eg. http://..)
-q --quiet suppress non-error messages
-n --dry-run trial run, don't delete any thumbnails. Most useful with increased verbosity
-v --verbose increase verbosity. May be specified more than once (more than 2 currently useless).

Contact

Markus Stumpf <srv-src-cleanthumbs@maexotic.de>

History

1.0 - 2010-04-16
initial release
Valid XHTML 1.0 Transitional Valid CSS! BY- CC-3.0 Copyright © 2010 Markus 'Maex' Stumpf
created: 2010-04-16 04:25:39 GMT+2
last modified: 2010-04-16 05:33:03 GMT+2