Last active
August 29, 2015 14:08
-
-
Save et4891/ab1e17fbaba7f2f10c28 to your computer and use it in GitHub Desktop.
Rename File Extention Only in Same Directory
This file contains 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 | |
// open the current directory (change this to modify where you're looking) | |
$dir = opendir('.'); | |
// loop through all the files in the directory | |
while (false !== ($file = readdir($dir))) | |
{ | |
// if the extension is '.jpg' | |
if (strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'html') | |
{ | |
// explode the filename so we can change the extension only and filename stays | |
$fileName = explode(".", $file); | |
// gets the first part of the filename after explode and change the extension | |
$newName = $fileName[0] . '.blade.php'; | |
// do the rename based on the current iteration | |
rename($file, $newName); | |
} | |
} | |
// close the directory handle | |
closedir($dir); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment