Share via


Powershell combine set of word docx into 1 file

Question

Friday, March 25, 2016 12:35 AM

Hi,

I am looking to combine my files in a folder.

These are word documents.  Docx

So far I have this - 

Get-ChildItem -path "C:\Users\plw\Desktop\Documents" -recurse |?{ ! $_.PSIsContainer } |?{($_.name).contains(".docx")} |
 %{ Out-File -filepath C:\Users\plw\Desktop\Output\ -inputobject (get-content $_.fullname) -Append}

Please advise - how can i combine all the docx in a folder into 1 file.

Thank you

All replies (5)

Friday, March 25, 2016 8:56 AM ✅Answered

Hi,

Besides jrv's suggestion, you could also look at the below article, it could also provide you a way to merge the mulitiple documents into one document.

https://blogs.technet.microsoft.com/heyscriptingguy/2005/05/03/how-can-i-insert-files-into-a-word-document/

Hope it helps.

Best Regards,

Elaine

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact [email protected].


Friday, March 25, 2016 12:55 AM

You cannot. Word files are not text files.  They are structured binaries that are creaked as compressed XML files (for DOCx, DOCm, etc.)

You must use MS Word to combine the files.  It is not  simple operation.

\(ツ)_/


Friday, March 25, 2016 1:20 AM

:(

aww thats too bad - powershell can't combine word docx.


Friday, March 25, 2016 3:03 AM

PowerShell can do it you just have to write a correct script.  It is not a one line solution.

\(ツ)_/


Friday, March 25, 2016 3:30 AM

If you search you can find many examples of how to do this: http://snipplr.com/view/20480/how-to-combine-multiple-word-documents-into-one-document/

\(ツ)_/