Skip to content

Instantly share code, notes, and snippets.

@ngharo
Created October 11, 2016 19:13
Show Gist options
  • Save ngharo/eadc96c52171759eeb0d396ad9b6e12d to your computer and use it in GitHub Desktop.
Save ngharo/eadc96c52171759eeb0d396ad9b6e12d to your computer and use it in GitHub Desktop.
bulk convert folder of docx files to pdfs
# Acquire a list of DOCX files in a folder
$Files=GET-CHLDITEM 'C:\FooFolder\*.DOCX'
Foreach ($File in $Files) {
# open a Word document, filename from the directory
$Doc=$Word.Documents.Open($File.fullname)
# Swap out DOCX with PDF in the Filename
$Name=($Doc.Fullname).replace("docx","pdf")
# Save this File as a PDF in Word 2010/2013
$Doc.saveas([ref] $Name, [ref] 17)
$Doc.close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment