Jump to content

Directory..move, rename, retain.


Ninjakreborn

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/189315-directorymove-rename-retain/
Share on other sites

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.