-
Notifications
You must be signed in to change notification settings - Fork 0
/
merge.bat
65 lines (47 loc) · 1.48 KB
/
merge.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
::------------------------------------------------------
:: Automatically merge all sqlite database files with
:: filename[dbName] from subdirectories in /databases
:: numbered 00, 01, ... 0N
::------------------------------------------------------
@echo off
:: maximum number of directories to traverse
:: starts at 00, 01, ... 0N
set /A maxDir=6
:: maximum number of wait interval in seconds
:: to process next database file
set /A maxSec=3
:: numerical directory index to start traversal
set /A index=0
:: sqlite database filename for each sub directory
set dbName=AppDataCollect.db
:: folder name containing 00,01,..0N database directories
set dbDirectory=databases
del /F /Q *.sql
GOTO Processing
:: export all rows from all tables in a database
:Processing
if %index% LSS 10 set dbfile=%dbDirectory%/0%index%/%dbName%
if %index% GEQ 10 set dbfile=%dbDirectory%/%index%/%dbName%
:: generate export data sql script
if exist %dbfile% (
@echo on
echo Exporting database %dbfile%'s contents...
:: export data
sqlite3 %dbfile% < settings/commands_tables.txt
:: insert exported data to master database
sqlite3 maindb.db < insert_data.sql
)
@echo off
:: increment directory index counter
set /A index += 1
:: clean residual files
del /F /Q *.sql
:: pause for [maxSec] seconds
choice /d y /t %maxSec% > nul
if %index% LSS %maxDir% GOTO Processing
if %index% EQU %maxDir% GOTO End
@echo off
:Error
echo Enter a database file name and try again
:End
pause;