Created
September 2, 2016 14:27
-
-
Save r4d10n/0f391587535dd135af54d06814ff359b to your computer and use it in GitHub Desktop.
Batch convert Pagemaker files to PDF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# An afternoon hack script to convert 100's of old Pagemaker files into PDF for reading | |
# Got tired looking for a good converter. Almost none exist..... Some bad business Adobe ! | |
# Requires Powershell, WASP, Adobe Pagemaker (running as PM70, modify otherwise) with Distiller PDF conversion support | |
# If some files are not converted, do a re-run of the script, which processes the PMD files for which PDF file has not been created. | |
$path = "C:\PDFCollection\" | |
$pmdfilelist = Get-ChildItem $path -filter *.pmd -recurse | |
$pdffilelist = Get-ChildItem $path -filter *.pdf -recurse # Do not modify. This is used for re-runs, if u missed to convert any file in the previous run | |
$pmdnum = $pmdfilelist | measure # Mostly from some odd job I found in stackoverflow.... Jai ho! | |
$pdfnum = $pdffilelist | measure | |
$filecount = $pmdnum.count - $pdfnum.count | |
$i = 0; | |
#ForEach ($file in $filelist) | |
Compare-Object $filelist $pdffilelist -Property baseName -passthru | Where-Object {$_.SideIndicator -eq "<="}| ForEach-Object { # Powershell rocks! | |
$i++; | |
$pmdfile = $_.fullName | |
$progress = ($i / $filecount) * 100 # Progress bar ! | |
$progress = [Math]::Round($progress,2) | |
Write-Host ------------------------------------------------------------------------------- | |
Write-Host "Processing - $pmdfile" | |
Write-Host "File $i of $filecount - $progress%" | |
Write-Host ------------------------------- | |
Select-Window PM70* | Send-Keys "%FO" # File -> Open | |
Select-Window PM70* | Select-ChildWindow | Send-Keys $pmdfile # Key-in filename | |
Select-Window PM70* | Select-ChildWindow | Send-Keys "%o" # Alt-O for Open | |
Select-Window PM70* | Select-ChildWindow | Send-Keys "~" # | |
Select-Window PM70* | Select-ChildWindow | Send-Keys "~" # Carriage Returns for handling some misc errors - Modify if not reqd. | |
Select-Window PM70* | Send-Keys "%fep" # File -> Export -> Adobe PDF | |
Start-Sleep -m 100 | |
Select-Window PM70* | Select-ChildWindow | Send-Keys "%e" # Export (Hopefully you have configured default settings) | |
Start-Sleep -m 100 | |
Select-Window PM70* | Select-ChildWindow | Send-Keys "%e" # Sometimes getting stuck at export ! | |
Select-Window PM70* | Select-ChildWindow | Select-ChildWindow | Send-Keys "%v%s" # No-view-pdf, Save | |
Select-Window PM70* | Select-ChildWindow | Select-ChildWindow | Select-ChildWindow | Send-Keys "%y" # Handle replace file (if it pops) | |
Select-Window PM70* | Select-ChildWindow | Select-ChildWindow | Send-Keys "~" # Handle some misc errors - Unable to view | |
Start-Sleep -m 200 | |
Select-Window PM70* | Send-Keys "^{F4}" # Close window | |
} # Loop on !! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I have tried this script but getting the following error-
Compare-Object : Cannot bind argument to parameter 'ReferenceObject' because it is null.
At C:\Users\DeLL\Desktop\pagemaker\pagemaker-to-pdf.ps1:19 char:15
ForEach-Object { # Powershell rocks!
ctCommand
please guide what am I doing wrong:?