Skip to content

Instantly share code, notes, and snippets.

@frankdejonge
Forked from AmyStephen/rename.php
Last active December 24, 2015 15:09
Show Gist options
  • Save frankdejonge/6818008 to your computer and use it in GitHub Desktop.
Save frankdejonge/6818008 to your computer and use it in GitHub Desktop.
<?php
$objects = new RecursiveIteratorIterator
(new RecursiveDirectoryIterator(__DIR__),
RecursiveIteratorIterator::SELF_FIRST);
foreach ($objects as $path => $fileObject) {
if ( ! is_dir($fileObject)) {
continue;
}
if ($fileObject->getFileName() == '.' || $fileObject->getFileName() == '..') {
continue;
}
$path = $fileObject->getPathName();
foreach (scandir($path) as $filename) {
if ($filename === '.' || $filename === '..') {
continue
}
$newname = preg_replace('"\.html.php"', '.phtml', $filename);
rename($path . '/' . $filename, $path . '/' . $newname);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment