Convert all doc items in a folder to pdf using powershell

Easy, fast and free

Source Stackoverflow


$documents_path = 'route to your docs folder'

$word_app = New-Object -ComObject Word.Application

# This filter will find .doc as well as .docx documents
Get-ChildItem -Path $documents_path -Filter *.doc? | ForEach-Object {

$document = $word_app.Documents.Open($_.FullName)

$pdf_filename = "$($_.DirectoryName)\$($_.BaseName).pdf"

$document.SaveAs([ref] $pdf_filename, [ref] 17)

$document.Close()
}

$word_app.Quit()

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.