-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.ahk
48 lines (39 loc) · 1.27 KB
/
template.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
#Include %A_ScriptDir%\base.ahk
#Include %A_ScriptDir%\lib.ahk
vWorkingDir := A_Args[1]
SetWorkingDir, %vWorkingDir%
vStepsTemplate := { 1_cleanup: 1
, 2_createfragdir: 0
, 3_templatefileexists: 0
, 4_templatefilecut: 0 }
FileDelete, template.log
if FileExist(vTemplateTokenDir) {
FileRemoveDir, %vTemplateTokenDir%, 1
if ErrorLevel
vStepsTemplate["1_cleanup"] := 0
}
if vStepsTemplate["1_cleanup"] {
FileCreateDir, %vTemplateTokenDir%
if !ErrorLevel
vStepsTemplate["2_createfragdir"] := 1
}
if vStepsTemplate["2_createfragdir"] {
if FileExist(vTemplateFile)
vStepsTemplate["3_templatefileexists"] := 1
}
if vStepsTemplate["3_templatefileexists"] {
Loop, read, %vTemplateFile%
{
if InStr(A_LoopReadLine, vCutPrefix) {
FileName := vTemplateTokenDir
. RTrim(LTrim(StrReplace(A_LoopReadLine, " ", ""), vCutPrefix), vCutSuffix)
. vFileExt
FileAppend, , %FileName%
}
else
FileAppend, %A_LoopReadLine%`n, %FileName%
}
if !ErrorLevel
vStepsTemplate["4_templatefilecut"] := 1
}
LogSteps("template", "", vStepsTemplate)