Skip to content

Instantly share code, notes, and snippets.

@kapb14
Last active June 22, 2016 08:56
Show Gist options
  • Save kapb14/4c2ce65b7fa0b46c8eed52c49ccada95 to your computer and use it in GitHub Desktop.
Save kapb14/4c2ce65b7fa0b46c8eed52c49ccada95 to your computer and use it in GitHub Desktop.
набросок скрипта. после запуска батника который подписывает, осуществляется проверка "есть ли одноименный файл во временной папке и в папке с подписанными файлами", если есть - удаляет файл из временной папки.
# define folders being used
$tmpdir = "c:\tmp_pdf"
$inputdir = "c:\in_pdf"
$signeddir = "c:\signed_pdf"
$outdir = "c:\out_pdf"
$x = "C:\sign_policy_cades_cleanCopy.bat"
while ($true)
{
Write-Verbose -Verbose "Run [$x] at ($(Get-Date))"
$inputFiles = Get-childitem $inputdir -filter *.pdf
Move-item $inputFiles.fullname -destination $tmpdir
# run .bat script without "move" commands here
Start-Process $x
$signedFiles = get-childitem $signeddir -filter *.pdf
$tmpFiles = get-childitem $tmpdir -filter *.pdf
# compare existing files in signed dir with files from tmp dir
ForEach ($file in $signedFiles){
ForEach ($tmpFile in $tmpFiles){
If ($tmpFile.Name -eq $file.Name){
Write-verbose -v "file is signed: $($file.Name)"
Remove-item $tmpFile.FullName
Move-item $file.fullname -destination $outdir
}
}
}
# report
$unsignedFiles = get-childitem $tmpdir
If ($unsignedFiles.Count){
Write-Warning -verbose "Unsigned files count: $(unsignedFiles.Count)"
} else {
write-verbose -v "All files have been signed. Ok."
}
Start-Sleep -Seconds 120
} #end Loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment