-
Notifications
You must be signed in to change notification settings - Fork 1
/
oneclick.bat
97 lines (89 loc) · 2.62 KB
/
oneclick.bat
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
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
SET ME=%~n0
SET PARENT=%~dp0
ECHO Preparing folders...
CALL CLEANUP > nul 2>&1
IF NOT EXIST temp MKDIR temp
IF NOT EXIST output MKDIR output
IF NOT EXIST badfiles MKDIR badfiles
IF NOT EXIST error MKDIR error
REM Detect whether the program runs on 64-bit OS by the existence of SysWOW64 folder.
ECHO Detecting system architecture...
IF EXIST "%SYSTEMROOT%\SysWOW64" (
SET AMD64=1
) ELSE (
SET AMD64=0
)
ECHO Checking scripts...
FOR /F %%f in ('type data\modules') DO (
IF NOT EXIST %%f ECHO %%F is missing && GOTO SELFCHECK_FAIL
)
ECHO Testing modules...
CALL SELFTEST >> selftest.log 2>&1
if %errorlevel% neq 0 GOTO SELFCHECK_FAIL
SET /a RETRY_COUNTER=0
SET /a RETRY_LIMIT=2
:AUTOPROCESS
ECHO Looking for files to import...
IF NOT EXIST *.swf (
ECHO There are no files left to import, exiting autoprocess
GOTO NORMAL_EXIT
) ELSE IF %RETRY_COUNTER% gtr %RETRY_LIMIT% (
SET /a RETRY_COUNTER+=1
CALL :FLUSH_ERROR >> export.log
SET /a RETRY_COUNTER=0
GOTO AUTOPROCESS
) ELSE IF EXIST "%PARENT%error\*.swf" (
SET /a RETRY_COUNTER+=1
MOVE /y "%PARENT%error\*.swf" "%PARENT%"
ECHO Importing files...
CALL IMPORT >> import.log 2>&1
CALL EXTRACT >> extract.log 2>&1
CALL SCALE 2>> scale.log
CALL REPLACE >> replace.log 2>&1
CALL EXPORT >> export.log 2>&1
GOTO AUTOPROCESS
) ELSE (
ECHO Importing files...
CALL IMPORT >> import.log 2>&1
CALL EXTRACT >> extract.log 2>&1
CALL SCALE 2>> scale.log
CALL REPLACE >> replace.log 2>&1
CALL EXPORT >> export.log 2>&1
GOTO AUTOPROCESS
)
:NORMAL_EXIT
CD %PARENT%
bin\doff.exe > time.date
set /p TIMESTAMP=<time.date
DEL /q time.date
ECHO Saving log to log_%TIMESTAMP%.txt...
COPY selftest.log + import.log + extract.log + scale.log + replace.log + export.log log_%TIMESTAMP%.txt > nul 2>&1
ECHO Removing temporary files...
CALL CLEANUP > nul 2>&1
ENDLOCAL
ECHO ----------------
ECHO Process Complete
ECHO ----------------
PAUSE
EXIT /B 0
:SELFCHECK_FAIL
ENDLOCAL
ECHO -----------------
ECHO Process Failed :(
ECHO -----------------
PAUSE
EXIT /B 1
:FLUSH_ERROR
ECHO The following files have failed after %RETRY_LIMIT% separate attempts, program will send them to %PARENT%badfiles...
ECHO The following files have failed after %RETRY_LIMIT% separate attempts, program will send them to %PARENT%badfiles...>CON
DIR /b "%PARENT%error\*.swf">CON
REM Lines for *.hack.swf for futureproofing
FOR /f "tokens=1 delims=." %%g IN ('DIR /b /a:-d "%PARENT%error\*.swf"') DO (
MOVE /y "%PARENT%error\%%g.swf" "%PARENT%badfiles"
REM MOVE /y "%PARENT%error\%%g.hack.swf" "%PARENT%badfiles"
DEL /q "%PARENT%\%%g.swf"
REM DEL /q "%PARENT%\%%g.hack.swf"
)
GOTO:EOF