Skip to content

Instantly share code, notes, and snippets.

@Vazkii
Created January 3, 2017 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vazkii/713bf7a66fd2bdf4fbe4ba5a1f45340d to your computer and use it in GitHub Desktop.
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
<?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