Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Append Test to test file name script
#!/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