Daniel K. Schneider wrote:
Hi,
(1) Does anyone have a a script that runs through $wgUploadPath and
converts the images to a /images/a/ab/foo.jpg structure ?
Someone already asked for this
(
http://www.mediawiki.org/wiki/Manual_talk:$wgHashedUploadDirectory) and
I searched for it in other places.
Reason: My wiki is growing, about 1000 images now and maybe I should act
better now than later.
It's not hard to write. Run this on the image folder:
moveToHashed.php
<?php
$hashLevels = 2;
$dir = opendir(".");
while (($file = readdir($dir)) !== false) {
if (!is_file($file)) continue;
echo "$file\n";
$md5 = md5($file);
$hexString = substr($md5, 0, $hashLevels );
$folder = "";
while (strlen($hexString) > 0) {
$folder = "$hexString/$folder";
$hexString = substr($hexString, 0, - 1);
}
mkdir($folder, 0777, true);
rename($file, "$folder$file");
}
closedir($dir);