Created
August 30, 2016 05:10
-
-
Save fullyninja/fb63726d999fd95f64596ebe82d4939b to your computer and use it in GitHub Desktop.
PowerShell Snippet to create empty Word documents given a text file with a list of file names.
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
$docListPath = "C:\temp\doclist.txt" | |
$docList = Get-Content $docListPath | |
$basePath = "c:\temp\docListOut\" | |
$word = New-Object -ComObject Word.Application | |
foreach ($fileName in $docList) | |
{ | |
$outPath = "$basePath$filename" | |
Write-Host "Creating $outPath" | |
# Create a new document. | |
$word.Application.Documents.Add() | |
$word.Application.ActiveDocument.SaveAs([ref]$outPath) | |
$word.Application.ActiveDocument.Close() | |
} | |
$word.Application.quit() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment