[SOLVED] relocate entire folder

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yaron
Forum Contributor
Posts: 157
Joined: Fri Aug 22, 2003 8:40 am

[SOLVED] relocate entire folder

Post by yaron »

Hello all,

I want to write a function that will get a current path and destination path and wil relocate an entire folder to the destination path.
I know how to move a file but not a folder that may contain subfolders as well.

any ideas?
Thanks
yaron
Forum Contributor
Posts: 157
Joined: Fri Aug 22, 2003 8:40 am

Post by yaron »

btw it runs under win 2000
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

i presume there isn't a move dir function.

You will probably need to take the following steps.

Traverse the directory you want to move, and create a replica directory structure in your intended destination.

Whilst traversing and creating the directory structure, you'll need to list the files, and moves them as you come across them.

Mark
yaron
Forum Contributor
Posts: 157
Joined: Fri Aug 22, 2003 8:40 am

Post by yaron »

hmm...
I was afraid of that... because my source dir can contain subdirs so i need to write some recursion which is a bad thing to do...
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

To move a folder and its subfolders, you could try (eg):

Code: Select all

system("move c:\\folder1\\folder3 c:\\folder3");
Seems to work ok for me under Win2K.
yaron
Forum Contributor
Posts: 157
Joined: Fri Aug 22, 2003 8:40 am

Post by yaron »

thanks a lot!!!
it is working!!!!!
Post Reply