Skip to content

Instantly share code, notes, and snippets.

@cdukes
Created May 10, 2015 09:12
Show Gist options
  • Save cdukes/d33714db6e66a4e1de97 to your computer and use it in GitHub Desktop.
Save cdukes/d33714db6e66a4e1de97 to your computer and use it in GitHub Desktop.
Remove WP-style generated images, leaving only the originals.
# OS X
# List affected files
find -E . -regex '.*/[-_a-zA-Z0-9]+-[0-9]+x[0-9]+\..+' -print -exec ls '{}' \;
# Remove affected files
find -E . -regex '.*/[-_a-zA-Z0-9]+-[0-9]+x[0-9]+\..+' -print -exec rm '{}' \;
# Downsize all images to 1200px
find . -iname "*.jpg" -type f -exec sh -c 'sips -Z 1200 "$0"' {} \;
# Linux
# OS X
# List affected files
find . -regex '.*/[-_a-zA-Z0-9]+-[0-9]+x[0-9]+\..+' -print -exec ls '{}' \;
# Remove affected files
find . -regex '.*/[-_a-zA-Z0-9]+-[0-9]+x[0-9]+\..+' -print -exec rm '{}' \;
# Downsize all images to 1200px
find . -iname "*.jpg" -type f -exec sh -c 'convert "$0" -resize 1200x1200\> "$0"' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment