Skip to content

Instantly share code, notes, and snippets.

@dingo-d
Created May 25, 2020 12:24
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 dingo-d/85adc0e185cae2734694c2537d76666f to your computer and use it in GitHub Desktop.
Save dingo-d/85adc0e185cae2734694c2537d76666f to your computer and use it in GitHub Desktop.
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