-
Notifications
You must be signed in to change notification settings - Fork 1
/
files.ahk
83 lines (67 loc) · 2.3 KB
/
files.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
#Include %A_ScriptDir%\base.ahk
#Include %A_ScriptDir%\lib.ahk
vWorkingDir := A_Args[1]
SetWorkingDir, %vWorkingDir%
vStepsFiles := { 1_cleanup: 1
, 2_createdistdir: 0
, 3_copytemplatefragdir: 0
, 4_copylocalfragdir: 0
, 5_copyfragfilecontent: 0
, 6_combine: 0
, 7_cleanupafter: 0 }
FileDelete, files.log
Loop, Files, %vFilesDir%%vTokenDir%, DR
{
vTmpPath := A_LoopFilePath . "\" . vTmpDir
vFinalPath := StrReplace(A_LoopFilePath, vSrc, vDist)
vFinalPath := StrReplace(vFinalPath, vTokenDir, "")
if FileExist(vTmpPath) {
FileRemoveDir, %vTmpPath%, 1
if ErrorLevel
vStepsFiles["1_cleanup"] := 0
}
if FileExist(vFinalPath) {
FileRemoveDir, %vFinalPath%, 1
if ErrorLevel
vStepsFiles["1_cleanup"] := 0
}
if vStepsFiles["1_cleanup"] {
FileCreateDir, %vFinalPath%
if !ErrorLevel
vStepsFiles["2_createdistdir"] := 1
}
if vStepsFiles["2_createdistdir"] {
FileCopyDir, %vTemplateTokenDir%, %vTmpPath%
if !ErrorLevel
vStepsFiles["3_copytemplatefragdir"] := 1
}
if vStepsFiles["3_copytemplatefragdir"] {
FileCopy, %A_LoopFilePath%\*%vFileExt%, %vTmpPath%, 1
if !ErrorLevel
vStepsFiles["4_copylocalfragdir"] := 1
}
if vStepsFiles["4_copylocalfragdir"] {
FileList := ""
Loop, Files, %vTmpPath%*%vFileExt%
FileList .= A_LoopFileName "`n"
Sort, FileList, N
Loop, parse, FileList, `n
{
if (A_LoopField = "")
continue
FileRead, Contents, %vTmpPath%%A_LoopField%
if !ErrorLevel
vStepsFiles["5_copyfragfilecontent"] := 1
if vStepsFiles["5_copyfragfilecontent"] {
FileAppend, %Contents%, %vFinalPath%%vFile%
Contents := ""
}
}
if !ErrorLevel
vStepsFiles["6_combine"] := 1
FileRemoveDir, %vTmpPath%, 1
if !ErrorLevel
vStepsFiles["7_cleanupafter"] := 1
}
LogSteps("files", vFinalPath, vStepsFiles)
}