duanba5777 2015-09-02 19:51
浏览 18

将目录的内容复制到许多其他子目录

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 ?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动