Skip to content

Instantly share code, notes, and snippets.

@voutilad
Created April 30, 2020 12:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save voutilad/1ecc4c2f496fc88dba56c638c8e25e32 to your computer and use it in GitHub Desktop.
Save voutilad/1ecc4c2f496fc88dba56c638c8e25e32 to your computer and use it in GitHub Desktop.
PowerShell to convert directory of PowerPoints into PDFs. Adapted from http://mike.clackjones.com/convert-directory-of-pptx-into-pdf-in-powershell/
$ppt = new-object -com powerpoint.application
$opt = [Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType]::ppSaveAsPDF
foreach($ifile in $(Get-ChildItem '.' -Filter '*.pptx')) {
$ifile = $ifile.FullName
$pres = $ppt.Presentations.Open($ifile)
$pathname = split-path $ifile
$filename = split-path $ifile -leaf
$file = $filename.split(".")[0]
$ofile = $pathname + "\\" + $file + ".pdf"
$pres.SaveAs($ofile, $opt)
$pres.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment