Entry
I'd like to move files into other directory...do you know some scripts who can help me..
Nov 13th, 2000 19:03
Paul Coldrey, fitton pascal, Ben Udall,
All you really need is the opendir(...), copy(...) and mkdir(...)
functions.
Here's a butchered version of something I wrote that might give you the
basic idea. The crux is this script is that I store an array of
directories that I still need to decend called $todo. The other trick
is you want to ignore the . and .. directories (otherwise it takes a
while to complete :-) ).
$start = "/someplace";
$end = "/someotherplace"
$todo = Array($start);
while($dir = array_pop($todo)) {
if(!is_dir("$end/$dir"))
if(!mkdir("$end/$dir",0777))
print("Failed to Create Directory $end/$dir<br>\n");
$handle=opendir($dir);
$d = dir($dir);
while($entry=$d->read()) {
if($entry[0] != '.') {
if(is_dir("$location"))
array_push($todo,"$location");
else
copy("$start/$entry", "$end/$entry");
}
}
$d->close();
closedir($handle);
}