-
Notifications
You must be signed in to change notification settings - Fork 0
/
Export_Import_Browser_Keywords.bat
85 lines (79 loc) · 2.06 KB
/
Export_Import_Browser_Keywords.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
@ECHO OFF
CHCP 65001 >NUL
CD /D %~DP0
SETLOCAL ENABLEDELAYEDEXPANSION
SET CURRENT_PATH=%~DP0
IF "%1"=="" (
SET "sqlPath=%~DP0Output\keywords.sql"
) ELSE (
SET "sqlPath=%~F1"
)
SET "sqlPath=%sqlPath:\=/%"
SET "scriptPath=%~DP0Output\ExportEdgeSqlScript"
IF EXIST "BrowserPath.ini" (
FOR /F "TOKENS=1,2 DELIMS==" %%i IN (BrowserPath.ini) DO (
SET "%%i=%%j"
IF ERRORLEVEL 1 (
ECHO;&ECHO Can not read BrowserPath.ini.
PAUSE && EXIT
)
)
) ELSE (
ECHO;&ECHO BrowserPath.ini not exist.
PAUSE && EXIT
)
IF NOT EXIST "%oldPath%\Web Data" (
ECHO;&ECHO Web Data on oldPath not existed, please modify BrowserPath.ini.
PAUSE && EXIT
)
IF NOT EXIST "%newPath%\Web Data" (
ECHO;&ECHO Web Data on newPath not existed, please modify BrowserPath.ini.
PAUSE && EXIT
)
IF NOT EXIST "%~DP0Output" md "%~DP0Output"
ECHO;&CHOICE /C EI /M "Do you want to export or import edge keywords?"
IF %ERRORLEVEL%==1 (
CALL :EXPORT_KEYWORDS
) ELSE (
CALL :IMPORT_KEYWORDS
)
PAUSE
EXIT
:EXPORT_KEYWORDS
ECHO;&ECHO Exporting edge keywords now ...
PUSHD
CD /D "%oldPath%"
ECHO .output "%sqlPath%" > "%scriptPath%"
ECHO .dump keywords >> "%scriptPath%"
"%CURRENT_PATH%sqlite3.exe" -init "%scriptPath%" "Web Data" .exit
"%CURRENT_PATH%sqlite3.exe" -csv "Web Data" "SELECT short_name, keyword, url FROM keywords;" > "%CURRENT_PATH%Output\keywords.csv"
POPD
DEL %scriptPath%
ECHO;&ECHO Finish exporting.
GOTO :EOF
:IMPORT_KEYWORDS
TASKLIST /FI "IMAGENAME EQ msedge.exe" 2>NUL | FIND /I /N "msedge.exe">NUL
IF %ERRORLEVEL%==0 (
ECHO;&ECHO Edge is running, do you want to force close it?
) ELSE (
ECHO;&ECHO Edge is not running.
GOTO DO_IMPORT
)
ECHO;&CHOICE /M "Please input Y or N: "
IF %ERRORLEVEL%==1 (
TASKKILL/IM msedge.exe /F >NUL 2>NUL
) ELSE (
GOTO IMPORT_KEYWORDS
)
:DO_IMPORT
ECHO;&ECHO Importing edge keywords now ...
PUSHD
CD /D "%newPath%"
ECHO DROP TABLE IF EXISTS keywords;> "%scriptPath%"
ECHO .read "%sqlPath%">> "%scriptPath%"
COPY "Web Data" "Web Data.backup"
"%CURRENT_PATH%sqlite3.exe" -init "%scriptPath%" "Web Data" .exit
POPD
DEL %scriptPath%
ECHO;&ECHO Finish importing.
GOTO :EOF