Created
May 25, 2020 12:24
-
-
Save dingo-d/85adc0e185cae2734694c2537d76666f to your computer and use it in GitHub Desktop.
Append Test to test file name script
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
#!/usr/bin/env php | |
<?php | |
function getDirs( $currentDir ) { | |
return array_filter( $currentDir, function ( $dir ) { | |
return is_dir( $dir ) && $dir !== '..' && $dir !== '.'; | |
} ); | |
} | |
function getFiles( $currentDir ) { | |
return array_filter( scandir( $currentDir ), function ( $file ) { | |
return ! is_dir( $file ) && $file !== '..' && $file !== '.'; | |
} ); | |
} | |
$dirs = getDirs( scandir( __DIR__ ) ); | |
foreach ( $dirs as $dir ) { | |
$files = getFiles( $dir ); | |
foreach ( $files as $file ) { | |
$newName = basename( $file, '.php' ) . 'Test.php'; | |
rename( dirname( __FILE__ ) . '/' . $dir . '/' . $file, dirname( __FILE__ ) . '/' . $dir . '/' . $newName ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment