-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathstep01_convert_docx.ps1
More file actions
26 lines (22 loc) · 888 Bytes
/
step01_convert_docx.ps1
File metadata and controls
26 lines (22 loc) · 888 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$word = new-object -ComObject word.application
$word.Visible = $false
$source_dir = 'C:/AutoMuse_Chapter_Planner/chapters_doc/'
$dest_dir = 'C:/AutoMuse_Chapter_Planner/chapters_txt/'
$saveFormat = [Enum]::Parse([Microsoft.Office.Interop.Word.WdSaveFormat], "wdFormatText");
$files = Get-ChildItem -Path $source_dir | Where-Object {$_.Name -like "*.docx"}
foreach ($file in $files)
{
Write-Host $file
# accept all
$doc = $word.Documents.Open($file.FullName)
#$doc.Revisions.AcceptAll()
$newname = $file.Name.Replace(".docx",".txt")
$doc.SaveAs([ref]($dest_dir + $newname), [ref]$saveFormat)
$doc.Close()
# reject all
#$doc = $word.Documents.Open($file.FullName)
#$doc.Revisions.RejectAll()
#$newname = $file.Name.Replace(".docx","_rejected.txt")
#$doc.SaveAs([ref]($dest_dir + $newname), [ref]$saveFormat)
#$doc.Close()
}