Created
January 3, 2017 00:22
-
-
Save Vazkii/713bf7a66fd2bdf4fbe4ba5a1f45340d to your computer and use it in GitHub Desktop.
Lowercases all files including .json contents. To help you port to 1.11. Made in php because that's just what I happened to have installed :V
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 | |
fix('.'); | |
function fix($path) { | |
echo "Fixing directory $path\n"; | |
$files = scandir($path); | |
echo "Found files " . implode($files, ' '). "\n\n"; | |
foreach($files as $file) { | |
if(strlen($file) <= 2) | |
continue; | |
$nextPath = "$path/$file"; | |
if(is_dir($nextPath)) | |
fix($nextPath); | |
else lowercase($nextPath); | |
} | |
} | |
function lowercase($file) { | |
$ext = substr($file, strrpos($file, '.')); | |
if($ext === '.lang') | |
return; | |
$contents = file_get_contents($file); | |
$newContents = $contents; | |
if($ext === '.json') | |
$newContents = lowercaseString($contents); | |
$newName = lowercaseString($file); | |
file_put_contents($newName, $newContents); | |
if($newName != $file) | |
unlink($file); | |
} | |
function lowercaseString($str) { | |
return strtolower(preg_replace("/([A-Z])/", '_$1', $str)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment