php Folder Merge

Discussion in 'PHP' started by Silver89, Jun 30, 2009.

  1. #1
    I have a few directories within a directory and I was wondering if there is a simple way to merge the directories or take all files within and put them into a new directory?

    Thanks
     
    Silver89, Jun 30, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Do you have shell access? You can easily move the files using a bash command. It's possible with php, but it would require a bunch of looping, and would take a while to write and execute the script to do it.

    If you get into the folder you want to move the files from, something like this should work:

    mv * /new/directory/

    If you're not afraid of overwriting anything you can use:

    mv -f * /new/directory/

    If you just want to copy the files:

    cp * /new/directory/

    or cp -f * /new/directory/
     
    jestep, Jun 30, 2009 IP
  3. Louis11

    Louis11 Active Member

    Messages:
    783
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    70
    #3
    If his web user has permissions to access the files, he could just use one of system(), passthru() . . . etc to execute the commands you provided. Assuming that this is in fact a linux/unix system?
     
    Louis11, Jun 30, 2009 IP