Skip to content

Instantly share code, notes, and snippets.

@hisnameisjimmy
Last active December 19, 2017 15:52
Show Gist options
  • Save hisnameisjimmy/5ff1afff30c1fe2285eba6e5b59e3d79 to your computer and use it in GitHub Desktop.
Save hisnameisjimmy/5ff1afff30c1fe2285eba6e5b59e3d79 to your computer and use it in GitHub Desktop.
Find all duplicate images from Wordpress
To see the list before deleting:
find -E . -regex '.*\-[0-9]{1,4}\x[0-9]{1,4}\.(png|gif|jpg)$' > ./duplicates.txt
To delete:
find -E . -regex '.*\-[0-9]{1,4}\x[0-9]{1,4}\.(png|gif|jpg)$' -delete
Run a find/replace on your mysqldump backup (and create a backup of that) to remove references to alternate wordpress files:
sed -i .bak -E 's#\-[0-9]{1,4}\x[0-9]{1,4}##g' backup.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment