Ninjakreborn Posted January 21, 2010 Share Posted January 21, 2010 I need to: 1) Take a directory named xxx (for example) that contains some files/folders ect... 2) Make a "exact copy" of that folder without harming, inadversely affecting, or deleting the original folder...but it'll be within the same folder...(will explain in a bit) 3) Rename the new folder to another name yyy (for example). Here is the catch. I need to have it structured like this. /MasterFolder /MasterFolder/xxx I need to copy that over to /MasterFolder/yyy This is something that I haven't been able to find any good solutions for online. My main question here..is that possible? Or do I have to do this the long way...by long way I mean: 1) Make a new folder named the new name of the folder they want. 2) Go and grab all the filenames from the folder that I want to mock from 3) Take each file separately and make a new copy of it in the other folder 4) Move over each folder in that xxx folder one at a time. I was hoping there was a way to: Grab folder, make a copy of it and rename it at the same time..I might be hoping for too much. Anyone done this before? Quote Link to comment https://forums.phpfreaks.com/topic/189315-directorymove-rename-retain/ Share on other sites More sharing options...
Catfish Posted January 21, 2010 Share Posted January 21, 2010 So you want ot be making a new folder called yyy and copying the contents of xxx to yyy? Quote Link to comment https://forums.phpfreaks.com/topic/189315-directorymove-rename-retain/#findComment-999441 Share on other sites More sharing options...
wildteen88 Posted January 21, 2010 Share Posted January 21, 2010 You could just use exec with the following command, eg exec('cp -r /path/to/xxx/folder /path/to/zzz/folder') However the above will only work for *nix based systems. Alternatively you can create a recursive function, such as the one posted in the user submitted comments for the copy function. Quote Link to comment https://forums.phpfreaks.com/topic/189315-directorymove-rename-retain/#findComment-999500 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.