Forgive me... I'm not much of a programmer.
I'm trying to write a php script for archiving that will tar up subdirectories to their own files.
ie:
/main/ ... archives to main.tar
/main/sub1 ... archives to main.sub1.tar
/main/sub2 ... archives to main.sub2.tar
/main/sub2/subsub1 ... archives to main.sub2.subsub1.tar
etc...
It needs to work with with unlimited subdirectories. I'll just go ahead and post what I've got so far so you can review it and tell me what an idiot I am. :-)
function tarEach($dir, $dest) {
chdir($dir);
$dh = opendir($dir);
while($fname = readdir($dh)) {
shell_exec("tar -cvf $dest/$fname.tar `find ./$fname -type f -maxdepth 1`");
if($fname!='.' && $fname!='..') {
if(is_dir($fname)) {
chdir($fname);
} else {
exit("All done!");
}
}
}
closedir($dh);
}
Clearly I'm going NOWHERE with this. Can some of you smart people point me in the right direction?