I have a some template files organised like this in a directory:
index.php
preferences.xml
user.xml
I have also have subdirectory of this directory that contains a large number of folders (the exact number of folders can change a lot) which have outdated versions of the above template files:
randomfolder1
randomfolder20
randomfolder29
...
I would like to be able to copy the template files into all of these folders in the subdirectory, regardless of how many directories or template files there are. This is an example of what I would like in every folder:
randomfolder
- index.php
- preferences.xml
- user.xml
I have used this to copy the template files into ONE directory, but not all of them:
$cdire = 'GMXD/Users/firstdirectory';
mkdir($cdire);
function recurse_copy($src,$dst) {
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src . '/' . $file,$dst . '/' . $file);
}
else {
copy($src . '/' . $file,$dst . '/' . $file);
}
}
}
closedir($dir);
}
recurse_copy('template',$cdire);
So how can you make this script copy all files in the template directory to all files in the subdirectory ?