multiple-pdf-password-remover
multiple-pdf-password-remover copied to clipboard
Searching qpdf.exe in CMDs %path% = $env:path
On my system I already have qpdf running.
It's /bin/ folder is also added to my CMDs %path%
variable.
To enable the PowerShell-Script Start-BulkRemovePdfPassword.ps1
to find "qpdf.exe" in $env:path
, I did the following changes to function Get-QpdfExeFilePath{}
....
function Get-QpdfExeFilePath {
### try { (Get-ChildItem -Path $PSScriptRoot -File -Recurse -Filter "qpdf.exe")[0].FullName }
### catch { $r = $null }
### return $r
# Check, if qpdf.exe is already found in PATH
$qpdfPath = Get-Command -Name qpdf.exe -ErrorAction SilentlyContinue
if ($qpdfPath) {
return $qpdfPath.Source
}
# Split PATH-Strings into single paths
$pathDirs = $env:PATH -split ';'
# Search single path for qpdf.exe
$qpdfPath = $pathDirs | ForEach-Object {
$fullPath = Join-Path $_ 'qpdf.exe'
if (Test-Path $fullPath) {
return $fullPath
}
}
# If qpdf.exe not found, return NullArray
if (-not $qpdfPath) {
return @()
}
return $qpdfPath
}
.