Usabolfazl commited on
Commit
d0d5781
·
verified ·
1 Parent(s): a659835

Upload scan2doc_oneclick.ps1 with huggingface_hub

Browse files
Files changed (1) hide show
  1. scan2doc_oneclick.ps1 +98 -0
scan2doc_oneclick.ps1 ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Scan2Doc Pro v6.0 - One-Click Installer for Windows
2
+ # Run this PowerShell script as Administrator
3
+
4
+ Write-Host "========================================" -ForegroundColor Cyan
5
+ Write-Host " Scan2Doc Pro v6.0 - Complete Installer" -ForegroundColor Cyan
6
+ Write-Host "========================================" -ForegroundColor Cyan
7
+ Write-Host ""
8
+
9
+ # Step 1: Install Python packages
10
+ Write-Host "[1/4] Installing Python packages..." -ForegroundColor Yellow
11
+ pip install opencv-python numpy pytesseract python-docx Pillow beautifulsoup4 lxml pymupdf pyinstaller customtkinter --quiet
12
+ if ($LASTEXITCODE -ne 0) {
13
+ Write-Host "Error installing packages!" -ForegroundColor Red
14
+ exit 1
15
+ }
16
+ Write-Host "Done!" -ForegroundColor Green
17
+
18
+ # Step 2: Download Tesseract portable
19
+ Write-Host ""
20
+ Write-Host "[2/4] Downloading Tesseract OCR..." -ForegroundColor Yellow
21
+ $tessDir = "$env:USERPROFILE\Tesseract-OCR"
22
+ if (-not (Test-Path $tessDir)) {
23
+ New-Item -ItemType Directory -Path $tessDir -Force | Out-Null
24
+ }
25
+
26
+ # Try to download from GitHub
27
+ $tessUrl = "https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-w64-setup-5.5.0.20241111.exe"
28
+ $tessExe = "$env:TEMP\tesseract_setup.exe"
29
+
30
+ try {
31
+ Write-Host "Downloading from official source..." -ForegroundColor Gray
32
+ [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
33
+ Invoke-WebRequest -Uri $tessUrl -OutFile $tessExe -UseBasicParsing
34
+
35
+ Write-Host "Installing Tesseract (silent)..." -ForegroundColor Gray
36
+ Start-Process -FilePath $tessExe -ArgumentList "/S", "/D=$tessDir" -Wait -NoNewWindow
37
+
38
+ # Add to PATH for current session
39
+ $env:PATH = "$tessDir;$env:PATH"
40
+
41
+ # Add to system PATH permanently
42
+ $currentPath = [Environment]::GetEnvironmentVariable("Path", "User")
43
+ if ($currentPath -notlike "*Tesseract*") {
44
+ [Environment]::SetEnvironmentVariable("Path", "$tessDir;$currentPath", "User")
45
+ Write-Host "Tesseract added to PATH!" -ForegroundColor Green
46
+ }
47
+
48
+ Write-Host "Done!" -ForegroundColor Green
49
+ } catch {
50
+ Write-Host "Auto-download failed. Please install manually:" -ForegroundColor Red
51
+ Write-Host " https://github.com/UB-Mannheim/tesseract/wiki" -ForegroundColor Yellow
52
+ Write-Host " Or run: winget install UB-Mannheim.TesseractOCR" -ForegroundColor Yellow
53
+ Write-Host ""
54
+ Read-Host "Press Enter after installing Tesseract"
55
+ }
56
+
57
+ # Step 3: Verify Tesseract
58
+ Write-Host ""
59
+ Write-Host "[3/4] Verifying Tesseract..." -ForegroundColor Yellow
60
+ $tesseractPath = "$tessDir\tesseract.exe"
61
+ if (Test-Path $tesseractPath) {
62
+ Write-Host "Tesseract found at: $tesseractPath" -ForegroundColor Green
63
+ } else {
64
+ # Try winget
65
+ Write-Host "Trying winget..." -ForegroundColor Gray
66
+ winget install UB-Mannheim.TesseractOCR --silent --accept-package-agreements --accept-source-agreements 2>$null
67
+ if ($LASTEXITCODE -eq 0) {
68
+ Write-Host "Tesseract installed via winget!" -ForegroundColor Green
69
+ } else {
70
+ Write-Host "Please install Tesseract manually and run this script again." -ForegroundColor Red
71
+ Read-Host "Press Enter to exit"
72
+ exit 1
73
+ }
74
+ }
75
+
76
+ # Step 4: Build exe files
77
+ Write-Host ""
78
+ Write-Host "[4/4] Building exe files..." -ForegroundColor Yellow
79
+
80
+ Write-Host "Building CLI version..." -ForegroundColor Gray
81
+ pyinstaller --onefile --console --clean --noconfirm --name=Scan2Doc_CLI scan2doc_pro_v6.py 2>$null
82
+
83
+ Write-Host "Building GUI version..." -ForegroundColor Gray
84
+ pyinstaller --onefile --windowed --clean --noconfirm --name=Scan2Doc_Pro --add-data="scan2doc_pro_v6.py;." scan2doc_gui_pro.py 2>$null
85
+
86
+ Write-Host ""
87
+ Write-Host "========================================" -ForegroundColor Cyan
88
+ Write-Host " Installation Complete!" -ForegroundColor Green
89
+ Write-Host "========================================" -ForegroundColor Cyan
90
+ Write-Host ""
91
+ Write-Host "EXE files are in: dist\ folder" -ForegroundColor Yellow
92
+ Write-Host ""
93
+ Write-Host "Usage:" -ForegroundColor White
94
+ Write-Host " Scan2Doc_CLI.exe -i image.jpg -o output.docx" -ForegroundColor Gray
95
+ Write-Host " Scan2Doc_CLI.exe -i document.pdf -o output.docx" -ForegroundColor Gray
96
+ Write-Host " Scan2Doc_Pro.exe (GUI - double click)" -ForegroundColor Gray
97
+ Write-Host ""
98
+ Read-Host "Press Enter to exit"