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
@echo off
REM =====================================================
REM 一鍵打包 PDF Keyword Finder (Windows 11 可攜版)
REM 作者: ChatGPT 客製 for 醫院使用
REM =====================================================

REM 檢查 Python 是否存在
python --version >nul 2>&1
if errorlevel 1 (
echo [錯誤] 找不到 Python,請先安裝 Python 並確保已加入 PATH。
pause
exit /b
)

echo.
echo 🔧 清理舊的 build / dist 資料夾...
rmdir /s /q build 2>nul
rmdir /s /q dist 2>nul
del /q main.spec 2>nul
echo ✅ 清理完成
echo.

echo 🚀 開始使用 PyInstaller 打包中,請稍候...
pyinstaller --onefile --noconsole ^
--add-data "tesseract;tesseract" ^
--add-data "poppler;poppler" ^
--icon "icon.ico" ^
main.py

if %errorlevel% neq 0 (
echo.
echo ❌ 打包過程發生錯誤,請檢查訊息。
pause
exit /b
)

echo.
echo ✅ 打包完成!
echo.
echo 輸出檔案位置:
echo dist\main.exe
echo.
echo 建議重新命名為:
echo PDF_keyword_finder.exe
echo.
pause