File: shrinkpix/collect-unshrunk-images.py (original) (raw)
#!/usr/bin/env python3 """
collect-unshrunk-images.py - extract all original images from a folder tree.
This is a utility script for shrinkpix.py, and shares the same date, author, license, etc., as that script. See https://learning-python.com/shrinkpix/.
PURPOSE
Run this script to pull all (or new) saved original images out of a tree. When first run, it moves all of the original-image backup subdirs created by shrinkpix to their same paths in a separate folder at the top of the tree. The backup folders by default show up at their root-relative paths in the automatically created ALLBACKUPSDIR ('_shrinkpix-all-originals') at the tree's root. ALLBACKUPSDIR can also be located elsewhere as an option.
The net effect extracts and isolates the original unshrunk images, and removes their backups from the folder tree. This may be useful to retain the unshrunk originals, but exclude them from uploaded website content.
When rerun after shrinking new images in a tree, this script simply copies the new originals to existing backup folders in ALLBACKUPSDIR, and removes the backups folders from the source tree. This allows you to shrink and collect a full tree, and later shrink and collect individual images added. Recollecting newly shrunk images this way assumes that you haven't renamed ALLBACKUPSDIR (else new backup folders will be moved to a new root folder).
USAGE
Command line: $ python3