-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.bat
More file actions
400 lines (324 loc) Β· 9 KB
/
update.bat
File metadata and controls
400 lines (324 loc) Β· 9 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
@echo off
setlocal enableextensions enabledelayedexpansion
title STL Bitz Box Updater
for /f %%a in ('copy /Z "%~dpf0" nul') do set "CR=%%a"
for /f %%a in ('"prompt $H &echo on &for %%B in (1) do rem"') do set BS=%%a
for /f %%a in ('echo prompt $E ^| cmd') do set "ESC=%%a"
goto MainMenu
:MainMenu
goto OBJtoSTL
:ExitMenu
goto End
:InstallServer
cls
title STL Bitz Box Updater
echo Ensuring server is launched in background . . .
start "Launching server . . ." STLBitzBoxServer.exe
echo\
goto ExitMenu
:OBJtoSTL
cls
title STL Bitz Box Update - OBJ to STL Converter
echo Creating new ^.STL files from ^.OBJ files found ^. ^. ^.!ESC![^?25l
set "reportconversion=reports\Report_FileConverted"
del "!reportconversion!.txt" >nul 2>&1
echo Creating new ^.STL files from ^.OBJ files found . . . >> !reportconversion!.txt
echo\ >> !reportconversion!.txt
set /a "convertedcount=0"
set "spinner=|"
for /r %%i in (*.obj) do (
set "str=%%i"
set str=!str:~0,-4!
set "stlstr=!str!.stl"
if "!spinner!" == "\" (
set "spinner=|"
)
if "!spinner!" == "-" (
set "spinner=\"
)
if "!spinner!" == "/" (
set "spinner=-"
)
if "!spinner!" == "|" (
set "spinner=/"
)
echo\
echo !ESC![0KThis may take a few minutes . . . !spinner!!ESC![0K
echo\
if NOT exist !stlstr! (
tools\assimp export "%%i" "!stlstr!" >> !reportconversion!.txt
set /a convertedcount += 1
echo Created new STL !stlstr!!ESC![0K
echo from file^: %%i!ESC![0K
echo Created new STL !stlstr! >> !reportconversion!.txt
echo from file^: %%i >> !reportconversion!.txt
)
echo !ESC![H
)
echo\
echo !convertedcount! ^.OBJ files required converting.
echo !convertedcount! ^.OBJ files required converting. >> !reportconversion!.txt
echo\
echo\ >> !reportconversion!.txt
echo End of report. >> !reportconversion!.txt
echo Report generated.
echo See !reportconversion!.txt for more details.
echo\
goto RebuildAll
:RebuildAll
cls
title STL Bitz Box Update - Thumbnail Generator
echo Generating thumbnails^.!ESC![^?25l
set /a "thumbcount=0"
set "spinner=|"
for /r %%i in (*.stl) do (
if "!spinner!" == "\" (
set "spinner=|"
)
if "!spinner!" == "-" (
set "spinner=\"
)
if "!spinner!" == "/" (
set "spinner=-"
)
if "!spinner!" == "|" (
set "spinner=/"
)
echo !ESC![0KThis may take a few minutes . . . !spinner!!ESC![0K
if NOT exist %%i.png (
tools\stltopng "%%i" -o "%%i.png" >nul 2>&1
set /a thumbcount += 1
echo\
echo Created %%i.png!ESC![0K
)
echo !ESC![H
)
echo\
echo\
echo\
echo\
echo !thumbcount! thumbnails required generation.
echo\
goto RebuildDB
:RebuildDB
cls
title STL Library Setup
set timestart=%time%
set /a count = 0
set /a cntpat = 0
set /a cntpro = 0
set /a countother = -1
set "dbfile=files\db"
set "db=!dbfile!"
set "top=files\top"
set "bot=files\bot"
set "index=index"
set "scriptpath=%~dp0"
set "tmphttp="
set "pa=files\db_pta"
set "pb=files\db_ptb"
set "pc=files\db_ptc"
set "pd=files\db_ptd"
set "pe=files\db_pte"
set "pf=files\db_ptf"
set "pg=files\db_ptg"
set "ph=files\db_pth"
set "pi=files\db_pti"
set "pj=files\db_ptj"
echo Removing old files . . .
echo\
echo Deleting index and DB files . . .
del !dbfile!.sdb >nul 2>&1
del !db!.sdb >nul 2>&1
del !pa!.sdb >nul 2>&1
del !pb!.sdb >nul 2>&1
del !pc!.sdb >nul 2>&1
del !pd!.sdb >nul 2>&1
del !pe!.sdb >nul 2>&1
del !pf!.sdb >nul 2>&1
del !pg!.sdb >nul 2>&1
del !ph!.sdb >nul 2>&1
del !pi!.sdb >nul 2>&1
del !pj!.sdb >nul 2>&1
del !index!.html >nul 2>&1
timeout /T 1 >nul
echo\
echo Getting file totals . . .
for /r %%a in ("*.stl") do (
set /a cntpat += 1
)
set /a "parts1=!cntpat!/10"
set /a "parts2=!cntpat!/10*2"
set /a "parts3=!cntpat!/10*3"
set /a "parts4=!cntpat!/10*4"
set /a "parts5=!cntpat!/10*5"
set /a "parts6=!cntpat!/10*6"
set /a "parts7=!cntpat!/10*7"
set /a "parts8=!cntpat!/10*8"
set /a "parts9=!cntpat!/10*9"
echo STL Files^: !cntpat!
echo\
timeout /T 1 >nul
set /A "est=!cntpat! / 60"
set /A "esthr=!est! / 60"
set /A "estmin= !est! - (60 * !esthr!)"
echo Estimated run time: !esthr!h !estmin!m.
title STL Library Setup - Started: %time:~,5% ^| Est. run-time: !esthr!h !estmin!m
echo\
timeout /T 1 >nul
echo Generating index HTML . . .
echo !ESC![^?25l
timeout /T 3 >nul
cls
for /r %%i in ("*.stl") do (
set /a count += 1
set "file=%%i"
call set "result=%%file:%scriptpath%=%%"
set "var1=!result!"
set "var2=!var1:*\=!"
for /f "delims=\" %%z in ("!var2!") do (set "lic=%%z")
set "str=!result!"
set str=!!result:~0,-4!
set "pngstr=!str!.stl.png"
set "txtstr=!str!"
set "txtstr=!txtstr:*\=!"
set "txtstr=!txtstr:*\=!"
for /f "delims=\" %%y in ("!txtstr!") do (set "dirstr=%%y")
set "readmetxt=!result!\..\..\README.txt"
set "licensetxt=!result!\..\..\LICENSE.txt"
set "tagstxt=!result!\..\..\TAGS.txt"
set "setdir=!result!\..\..\"
set "setfiles=!result!\..\"
set "txtstr=!txtstr:*\=!"
if !count! leq !cntpat! (
set "dbfile=!pj!"
)
if !count! leq !parts9! (
set "dbfile=!pi!"
)
if !count! leq !parts8! (
set "dbfile=!ph!"
)
if !count! leq !parts7! (
set "dbfile=!pg!"
)
if !count! leq !parts6! (
set "dbfile=!pf!"
)
if !count! leq !parts5! (
set "dbfile=!pe!"
)
if !count! leq !parts4! (
set "dbfile=!pd!"
)
if !count! leq !parts3! (
set "dbfile=!pc!"
)
if !count! leq !parts2! (
set "dbfile=!pb!"
)
if !count! leq !parts1! (
set "dbfile=!pa!"
)
echo !ESC![0K!ESC![1A!ESC![0KRebuilding database . . .!ESC![0K
echo !ESC![0K
echo !ESC![0KAdding entry^: !count! of !cntpat!!ESC![0K
echo !ESC![0KSTL file^: !txtstr!.stl!ESC![0K
echo ^<tr^> >> !dbfile!.sdb
echo ^<td^> >> !dbfile!.sdb
echo ^<div class="tooltip-item"^>^<a href="#"^>^<img src="" data-src="!pngstr!" width="96" height="96"^>^</a^>^</div^> >> !dbfile!.sdb
echo ^</td^> >> !dbfile!.sdb
echo ^<td^> >> !dbfile!.sdb
echo ^<a href="!result!" target="_blank"^>^<p^> πΎ .STL^</p^>^</a^> >> !dbfile!.sdb
set "viewpath=!result!"
set "viewpath=!viewpath:\=/!"
echo ^<a href="viewer.html" target="_blank" onClick="loadSTLView('!viewpath!')"^>^<p^> π 3D VIEW^</p^>^</a^> >> !dbfile!.sdb
if exist !readmetxt! (
echo ^<a href="!readmetxt!" target="_blank"^>^<p^> π README^</p^>^</a^> >> !dbfile!.sdb
) else (
echo ^<p^> π« README^</p^> >> !dbfile!.sdb
)
if exist !readmetxt! (
for /f "usebackq delims=" %%h in ("!readmetxt!") do for %%l in (%%h) do (
set "varhttp=%%~l"
set "varhttp=!varhttp:>=!"
set "varhttp=!varhttp:"=!"
if NOT "!varhttp!" == "!tmphttp!" (
if "!varhttp:~0,4!" == "http" (
echo !ESC![0KLink^: !varhttp!!ESC![0K
echo ^<a href="!varhttp!" target="_blank"^>^<p^> π LINK^</p^>^</a^> >> !dbfile!.sdb
set "tmphttp=!varhttp!"
)
) else (
echo !ESC![0KLink^: !varhttp!!ESC![0K
echo ^<a href="!varhttp!" target="_blank"^>^<p^> π LINK^</p^>^</a^> >> !dbfile!.sdb
)
)
) else (
set "varhttp="
)
if NOT "!varhttp:~0,4!" == "http" (
echo !ESC![0KLink^: No link present.!ESC![0K
echo ^<p^> π« LINK^</p^> >> !dbfile!.sdb
)
echo ^</td^> >> !dbfile!.sdb
echo ^<td^> >> !dbfile!.sdb
if exist "!licensetxt!" (
echo ^<a href="!licensetxt!" target="_blank"^> !lic! ^</a^> >> !dbfile!.sdb
) else (
echo ^<p^> !lic! ^</p^> >> !dbfile!.sdb
)
echo ^</td^> >> !dbfile!.sdb
echo ^<td^>^<a href="!setdir!" target="_blank"^>!dirstr!^</a^>^</td^> >> !dbfile!.sdb
echo ^<td^>^<a href="!setfiles!" target="_blank"^>!txtstr!^</a^>^</td^> >> !dbfile!.sdb
if exist "!tagstxt!" (
for /f "usebackq delims=:" %%x in ("!tagstxt!") do (
echo ^<td^>%%x^</td^> >> !dbfile!.sdb
)
) else (
echo ^<td^>none^</td^> >> !dbfile!.sdb
)
echo ^</tr^> >> !dbfile!.sdb
rem pathping 127.0.0.1 -n -q 1 -p 150 >nul
echo !ESC![^?25l
echo !ESC![H
echo !ESC![4B!ESC![0J
echo !ESC![H
)
title STL Library Setup - Finalising...
copy /b !pa!.sdb +!pb!.sdb +!pc!.sdb +!pd!.sdb +!pe!.sdb +!pf!.sdb +!pg!.sdb +!ph!.sdb +!pi!.sdb +!pj!.sdb !db!.sdb >nul 2>&1
copy /b !top!.html +!db!.sdb +!bot!.html !index!.html >nul 2>&1
cls
echo Database rebuild complete.
set timeend=%time%
set chunks="tokens=1-4 delims=:.,"
for /f %chunks% %%a in ("!timestart!") do (
set "starthr=%%a"
set /a "startm=100%%b %% 100"
)
for /f %chunks% %%a in ("!timeend!") do (
set "endhr=%%a"
set /a "endm=100%%b %% 100"
)
set /a "hrs=!endhr! - !starthr!"
set /a "mins=!endm! - !startm!"
if !secs! lss 0 (
set /a "mins= !mins! - 1"
)
if !mins! lss 0 (
set /a "hrs= !hrs! - 1"
set /a "mins = 60!mins!"
)
if !hrs! lss 0 (
set /a "hrs= 24!hrs!"
)
echo\
echo Execution completed in !hrs!h !mins!m
echo\
rundll32.exe cmdext.dll,MessageBeepStub
echo\
echo Launching page . . .
timeout 2 >nul
start http://stlbitzbox.local
goto InstallServer
:End