Copying the contents of one or more word document into another word document

Welcome Forums General PowerShell Q&A Copying the contents of one or more word document into another word document

Viewing 3 reply threads
  • Author
    Posts
    • #165577
      Participant
      Topics: 3
      Replies: 3
      Points: 43
      Rank: Member

      Hi,

       

      I am trying to use the following command:

      gc  03.docx | sc c:\Test\04.docx

       

      but when it creates the file 04.docx, it can’t be opened by Microsoft Word. Please help.

    • #165595
      Senior Moderator
      Topics: 9
      Replies: 1236
      Points: 4,443
      Helping Hand
      Rank: Community Hero

      What are you trying to achieve here. If your intend is to change extension, you should use Rename-Item cmdlet.

      Get-Help Rename-Item -Online

      btwn, just changing the extension doesn’t make doc to docx, i believe.

    • #165598
      Participant
      Topics: 5
      Replies: 2368
      Points: 5,987
      Helping Hand
      Rank: Community MVP

      Please format your code as code using the code tag button (pre) provided. Thanks.

      Why don’t you simply copy the complete file?

      Copy-Item -Path 03.docx -Destination c:\Test\04.docx
    • #165658
      Participant
      Topics: 1
      Replies: 64
      Points: 363
      Helping Hand
      Rank: Contributor

      So, docx is format file (not plain text), for a ‘test’ go ahead and do get-content 03.docx. What you’ll notice is a LOT of gibberish to the screen.

      If you want to save multiple .docx files to a new docx file, you’re going to need to be able to read the document properly first. There are some conversations of doing this online.

      https://blogs.technet.microsoft.com/bshukla/2010/07/28/how-to-convert-a-word-document-to-other-formats-using-powershell/

Viewing 3 reply threads
  • The topic ‘Copying the contents of one or more word document into another word document’ is closed to new replies.