Created
December 3, 2014 00:33
-
-
Save jstnkrr/9355a84380181aef9185 to your computer and use it in GitHub Desktop.
Script to clean WP content upload folder of resized images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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