Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sometimes you only want the original images and not the generated sizes <name-of-image>-150x150.png. This command deletes all the files with a certain pattern in the file name.
# List the files
find -E . -type f -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)"
# DANGER! Delete the files
find -E . -type f -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -delete
# Regenerate all media files and sizes
wp media regenerate --yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment