Skip to content

Instantly share code, notes, and snippets.

@jstnkrr
Created December 3, 2014 00:33
Show Gist options
  • Save jstnkrr/9355a84380181aef9185 to your computer and use it in GitHub Desktop.
Save jstnkrr/9355a84380181aef9185 to your computer and use it in GitHub Desktop.
Script to clean WP content upload folder of resized images
<?php
$Directory = new RecursiveDirectoryIterator('../legacy/wp-content/uploads/');
$Iterator = new RecursiveIteratorIterator($Directory);
$i = 0;
foreach($Iterator as $name => $object){
if (!preg_match('/[\_\-]\d+x\d+\./i', $name)) continue;
//if ($i > 20) break;
echo "$name\n";
unlink($name);
$i++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment