-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathFileMgmt.ahk
98 lines (81 loc) · 2.92 KB
/
FileMgmt.ahk
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#INCLUDE C:\Users\UserData\DEV\AHK\00_INCLUDE\MyLibraries\TheArkyTekt_Tokens.ahk
#INCLUDE C:\Users\UserData\DEV\AHK\00_INCLUDE\MyLibraries\TheArkyTekt_Hash.ahk
SrcDir := "C:\Users\Jeb6\AppData\Roaming\foobar2000"
DestDir := "D:\_BACKUP_\BackupScriptDest"
qt2(InStr) {
return Chr(34) . InStr . Chr(34)
}
nl2() {
return Chr(13) . Chr(10)
}
xsync(SrcDir,DestDir,True)
xsync(SrcDir,DestDir,CleanDir:=False) {
DebugNow := 0
DebugList := "HashMismatchList"
Bytes := 0
SrcFolderStruct := ""
DestFolderStruct := ""
FileCopyList := ""
TempDigest := A_WorkingDir . "\TempDigest.txt"
; make src folder heirarchy list first
Loop, Files, %SrcDir%\*, DR
{
If (SrcFolderStruct = "") {
SrcFolderStruct := A_LoopFileFullPath
} Else {
SrcFolderStruct .= Chr(13) . Chr(10) . A_LoopFileFullPath
}
}
If (CleanDir = True) {
; list folders in dest
Loop, Files, %DestDir%\*, DR
{
If (DestFolderStruct = "") {
DestFolderStruct := A_LoopFileFullPath
} Else {
DestFolderStruct .= Chr(13) . Chr(10) . A_LoopFileFullPath
}
}
; MsgBox DestFolderStruct: %DestFolderStruct%
; delete dest folders not in src list
Loop, Parse, DestFolderStruct, `r, `n
{
CurDestFolder := StrReplace(A_LoopField,DestDir,"")
m := False
; look for match in src folder list
Loop, Parse, SrcFolderStruct, `r, `n
{
CurSrcFolder := StrReplace(A_LoopField,SrcDir,"")
; MsgBox % "Dest: " . qt2(CurDestFolder) . nl2() . "Src: " . qt2(CurSrcFolder)
If (CurSrcFolder = CurDestFolder) {
m := True
; MsgBox MATCH
break
}
}
; MsgBox % "m: " . m . nl2() . "Fldr: " . CurDestFolder
; remove if match found
If (m = False And CurDestFolder <> "") {
FileRemoveDir, %A_LoopField%, 1
}
}
}
; create folder heirarchy in dest
Loop, Parse, SrcFolderStruct, `r, `n
{
If (A_LoopField <> "") {
DestItem := StrReplace(A_LoopField,SrcDir,DestDir)
FileCreateDir, %DestItem%
}
}
; create / compare hashes
; hash Src folder (to temp file - relative paths)
; compare to test folder > output var
; parse output var
; copy each file parsed (substitution needed)
; done
}