#This script downloads and installs 7-zip(used to install TessNet2) and Tessnet2.
#The 7-zip downloaded and installed is for 64 bit computers in C:\Program Files\7-Zip
#The Tessnet2 and TessNet2 English data are stored in $Home\Programming\TessNet2 directory.
$Date = [System.datetime]::now. ToString("yyyy-MM-dd")
$Junk = "$Home\Junk$Date"
if(!$(Test-Path $Junk)) { $void = New-Item -ItemType directory -Path $Junk }
#If 7-zip is not installed (it is needed to extract the data .gz file)
if(!$(Test-Path "C:\Program Files\7-Zip")) {
write-host "Downloading 7-Zip"
$webclient = New-Object System.Net.WebClient
$file = "$Junk\7z920-x64.msi"
$webclient.DownloadFile($url,$ file)
write-host "Installing 7-Zip"
Start-Process -file "$Junk\7z920-x64.msi" `
-arg ' /qn INSTALLDIR="C:\Program Files\7-Zip" ' `
-passthru | wait-process
}
#Create a programming folder in our Home directory.
$pgmDirectory = "$Home" + "\programming"
if(!$(Test-Path $pgmDirectory)) { $void = New-Item -ItemType directory -Path $pgmDirectory }
#Create a TessNet2 folder in our Programming directory.
$TNetDirectory = $pgmDirectory + "\TessNet2"
if(!$(Test-Path $TNetDirectory)) { $void=New-Item -ItemType directory -Path $TNetDirectory }
#If the TessNet language pack is not downloaded yet, download and extract it.
$TDataDirectory = $TNetDirectory + "\tessdata"
if(!$(Test-Path $TDataDirectory)) {
write-host "Downloading TessNet2 Data"
$webclient = New-Object System.Net.WebClient
$file = "$Junk\tesseract-2.00.eng.tar. gz"
$webclient.DownloadFile($url,$ file)
write-host "Installing TessNet2 Data"
$void = & "C:\Program Files\7-Zip\7z.exe" "x" "$Junk\tesseract-2.00.eng.tar. gz" "-o$Junk"
$void = & "C:\Program Files\7-Zip\7z.exe" "x" "$Junk\tesseract-2.00.eng.tar" "-o$TNetDirectory"
}
#If the TessNetAssemblies are not downloaded yet, download and extract them
$TAssDirectory = $TNetDirectory + "\TessNetAssemblies"
if(!$(Test-Path $TAssDirectory)) {
write-host "Downloading TessNet2 Assemblies"
$void=New-Item -ItemType directory -Path $TAssDirectory
$webclient = New-Object System.Net.WebClient
$url = "http://tmp.m4f.eu/tessnet2. zip"
$file = "$Junk\tessnet2.zip"
$webclient.DownloadFile($url,$ file)
write-host "Installing TessNet2 Assemblies"
$void = & "C:\Program Files\7-Zip\7z.exe" "x" "$Junk\tessnet2.zip" "-o$TAssDirectory"
}
Remove-Item $Junk -Force -Recurse
#Run this commented out section to uninstall TessNet2 (Ensure any applications (including PowerShell) that have used it are closed first).
#This uninstalled assummes that you have it installed in the same directories this script installed it to.
$unstlDirectory = "$Home" + "\programming" + "\TessNet2"
Remove-Item $unstlDirectory -Force -Recurse
#>
No comments:
Post a Comment