How to Convert Old Word .doc Files to .docx in Bulk via PowerShell
🔍 WiseChecker

How to Convert Old Word .doc Files to .docx in Bulk via PowerShell

If you manage a large folder of legacy Word documents saved in the older .doc format, opening each file one by one to convert it to .docx wastes time. The .doc format is the binary format used by Word 97 through Word 2003, while .docx is the newer XML-based format introduced in Word 2007. This article explains how to use a PowerShell script to convert all .doc files in a folder to .docx format in a single operation.

The script automates Word through its COM object model, opening each .doc file and saving it as .docx without manual intervention. You do not need to install extra software beyond Word and PowerShell, both of which are included in Windows 10 and Windows 11. After following this guide, you will be able to run the conversion on any folder and optionally delete the original .doc files.

Key Takeaways: Bulk .doc to .docx Conversion via PowerShell

  • PowerShell script with Word COM object (New-Object -ComObject Word.Application): Opens Word in the background and automates file conversion without showing the Word window.
  • Get-ChildItem -Filter doc: Finds all .doc files in a folder and its subfolders for batch processing.
  • Document.SaveAs2 method with wdFormatDocumentDefault (16): Saves each file as .docx using Word’s default format constant.

ADVERTISEMENT

Why Use PowerShell for Bulk .doc to .docx Conversion

Word can open .doc files natively and save them as .docx, but it lacks a built-in batch conversion tool. The graphical interface requires you to open each file, choose Save As, select the .docx format, and confirm the save location. For hundreds of files, this process is impractical.

PowerShell can automate Word by using the COM (Component Object Model) interface. The script launches an invisible instance of Word, opens each .doc file, saves it as .docx using the wdFormatDocumentDefault constant (value 16), and then closes the document. The script runs entirely in the background and does not interfere with your other work.

Prerequisites for this method:

  • Word installed on the computer (any edition from 2007 onward works).
  • PowerShell 5.0 or later, which is included with Windows 10 and Windows 11.
  • Write permissions to the folder where the .doc files reside. The script saves the .docx files in the same folder.
  • Original .doc files must not be password-protected or corrupted. The script skips files that cause errors.

Steps to Convert .doc Files to .docx in Bulk

Follow these steps exactly. The script processes all .doc files in the folder you specify. It does not modify the original files unless you add the deletion step at the end.

  1. Open PowerShell as Administrator
    Click the Start button, type PowerShell, right-click Windows PowerShell in the results, and select Run as administrator. Confirm the User Account Control prompt. Running as administrator ensures the script can access all folders without permission errors.
  2. Set the execution policy to allow scripts (if needed)
    PowerShell may block script execution by default. Type the following command and press Enter:
    Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
    This change applies only to the current PowerShell session. It allows the script to run once without altering the system-wide policy.
  3. Copy the conversion script into PowerShell
    Copy the following script block and paste it into the PowerShell window by right-clicking the window title bar and selecting Edit > Paste. Replace C:\Path\To\Your\Folder with the actual folder path containing your .doc files.
    
    $folderPath = "C:\Path\To\Your\Folder"
    $wordApp = New-Object -ComObject Word.Application
    $wordApp.Visible = $false
    
    Get-ChildItem -Path $folderPath -Filter doc -Recurse | ForEach-Object {
        $docPath = $_.FullName
        $docxPath = [System.IO.Path]::ChangeExtension($docPath, ".docx")
        try {
            $doc = $wordApp.Documents.Open($docPath)
            $doc.SaveAs2([ref] $docxPath, [ref] 16)
            $doc.Close()
            Write-Host "Converted: $docPath"
        } catch {
            Write-Host "Failed: $docPath - $_"
        }
    }
    
    $wordApp.Quit()
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($wordApp) | Out-Null
    
  4. Run the script
    Press Enter to execute the script. PowerShell processes each .doc file in the specified folder and all subfolders. A progress message appears for each file: Converted: C:\Docs\report.doc for success, or Failed: C:\Docs\old.doc – error message for any file that could not be opened.
  5. Verify the converted .docx files
    Open the folder in File Explorer. You should see a .docx file next to each original .doc file. Open a few .docx files in Word to confirm the content, formatting, and images are intact. The script preserves the original file name and changes only the extension.
  6. Delete the original .doc files (optional)
    If you are certain the conversions are correct, you can remove the old .doc files. Add this line before $wordApp.Quit() in the script:
    Remove-Item -Path $docPath -Force
    Run the script again on the same folder. The deletion is permanent and bypasses the Recycle Bin, so test the script on a backup copy first.

ADVERTISEMENT

Common Issues and How to Handle Them

The script runs but no .docx files appear in the folder

This happens when the folder path in the script points to a location that does not contain .doc files. Verify the $folderPath variable uses the correct full path. The path must not include trailing spaces or quotes inside the string. Run Get-ChildItem -Path $folderPath -Filter doc in PowerShell to list all .doc files before running the conversion script.

Word opens and closes repeatedly during the script

The script sets $wordApp.Visible = $false to hide the Word window. If Word still appears, a different process may be interfering. Close all open Word documents before running the script. If the issue persists, restart Windows to clear any stuck COM objects.

Error: “Cannot open document” for a specific file

The .doc file may be corrupted, password-protected, or saved in a format Word cannot read. Open that file directly in Word. If Word cannot open it, the file is not recoverable through automation. If the file is password-protected, you must remove the password manually before the script can convert it.

PowerShell returns “Object not set to an instance of an object”

This error occurs when the New-Object -ComObject Word.Application command fails. Word may not be installed, or the COM registration is broken. Reinstall Word or run Repair from the Office installation program in Control Panel > Programs > Microsoft Office > Change > Quick Repair.

PowerShell Script vs Manual Conversion in Word

Item PowerShell Script Manual Conversion (Word)
Time for 100 files 5–10 minutes (unattended) 60–90 minutes (active)
User interaction required None after launching script Open, Save As, select format, close per file
Risk of human error Low (consistent output) High (skipping files, wrong format)
Subfolder support Yes, with -Recurse parameter No, must navigate manually
Skill level required Intermediate (PowerShell basics) Beginner

The PowerShell script is the faster and more reliable method for converting many .doc files. Manual conversion is only suitable for one or two files.

You can now convert an entire folder of legacy .doc files to the modern .docx format without opening each file manually. Test the script on a backup copy of your files before running it on your main archive. For an extra layer of safety, add the -WhatIf parameter to the Remove-Item command to preview which files would be deleted without actually removing them.

ADVERTISEMENT