copy and paste to multiple folders at same time

Discussion in 'Programming' started by ssnet, Jan 18, 2008.

  1. #1
    hi i am building a website.

    i have about 900 folders which will be going in my root directory.

    each folder will have 4 files in it.

    i need these 4 files in all of the 900 folders.

    i can only see how to do it by copying and pasting the 4 files into each folder 1 by 1.

    this is slow and tedious. is there a way so that i can paste them to all 900 folders at the same time?

    so then all 900 folders have 4 files in each one.

    or maybe a script to do this.

    thanks

    steve
     
    ssnet, Jan 18, 2008 IP
  2. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <?php
    
    $files = array('file1','file2','file3','file4');
    
    if ($handle = opendir('.')) {
        while (false !== ($file = readdir($handle))) {
            if (is_dir($file)) {
                copy($files[0], $file . '/' . $files[0]);
                copy($files[1], $file . '/' . $files[1]);
                copy($files[2], $file . '/' . $files[2]);
                copy($files[3], $file . '/' . $files[3]);
            }
        }
        closedir($handle);
    }
    
    ?>
    PHP:
    Should work
     
    decepti0n, Jan 18, 2008 IP
  3. ssnet

    ssnet Peon

    Messages:
    312
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi thanks deception but is there a way to do it on my computer instead of my webserver.

    thanks steve
     
    ssnet, Jan 18, 2008 IP