-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackup.php
54 lines (46 loc) · 1.74 KB
/
backup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
// zip and backup manga
require 'FolderWalker.class.php';
class Backup_Manga extends FolderWalker {
// protected $source = 'D:\Manga\# By Author';
protected $source = 'D:\Manga\# By Volume';
// protected $dest = 'F:\Manga\# By Author';
protected $dest = 'F:\Manga\# By Volume';
protected function shouldProcessFolder(DirectoryIterator $pParent, DirectoryIterator $pNode) {
return true;
}
protected function processFolder(DirectoryIterator $pParent, DirectoryIterator $pNode) {
$pNode = new DirectoryIterator($pNode->getPathname());
$tSource = $this->source;
$tDest = $this->dest;
$this->source = $tSource.'\\'.$pParent->getBasename();
$this->dest = $tDest.'\\'.$pParent->getBasename();
if (!is_dir($this->dest)) mkdir($this->dest);
while ($pNode->valid()) {
$node = $pNode->current();
if ($node->isDir() && $node->isReadable() && !$node->isDot()) {
$this->backupFolder($pNode, $node);
}
$pNode->next();
}
$this->source = $tSource;
$this->dest = $tDest;
}
protected function backupFolder(DirectoryIterator $pParent, DirectoryIterator $pNode) {
$p7z = '"E:\Program Files\7-Zip\7z.exe" a -tzip -mx0';
$inpath = '"'.$this->source.'\\'.$pNode->getBasename().'\\*"';
$outfile = '"'.$this->dest.'\\'.$pNode->getBasename().'.zip"';
echo "$p7z $outfile $inpath\r\n";
}
protected function shouldProcessFile(DirectoryIterator $pParent, DirectoryIterator $pNode) {
return false;
}
protected function processFile(DirectoryIterator $pParent, DirectoryIterator $pNode) {
}
protected function shouldBrowseFolder(DirectoryIterator $pParent, DirectoryIterator $pNode) {
return false;
}
}
$a = new Backup_Manga;
// $a->startWalking('D:\Manga\# By Author', false);
$a->startWalking('D:\Manga\# By Volume', false);