MD Factory saves one Markdown file for each document. To get a single file, convert the documents first, then join the Markdown files with a short PowerShell command that adds a source line before each one.

The result is one file in which every document starts with the name of its source. The pictures keep working, because the combined file sits next to the images folders.

Four small stacks of paper beside one thick stack held by a lilac binder clip, with a lilac pencil in front.
Several documents, one file.

When one file helps

One file is handy when a tool accepts a single upload or limits how many files you can attach, when you want to read several documents as one text, or when you want to paste a whole set into one prompt.

Keep one file per document when a coding agent will search the folder. It can open just the file it needs, and the file name tells the source: see how to give Claude Code, Cursor and Codex your PDFs and Word files. Combine only documents that belong together, because a very long file can be more than an AI tool reads at once.

Convert the documents

  1. Put the documents that belong together into one folder.
  2. Open MD Factory, click Add folder and choose it. Conversion starts right away, and each Markdown file is saved next to its original.
  3. Wait until every row shows Completed, Needs review or Failed. Click Needs review to read what to check, and fix those parts before you join the files.

The command below joins every .md file in a folder, so convert only what you want in the combined file. Delete numbered copies such as Budget (2).md first if you do not want them in it.

Join the files with PowerShell

  1. In File Explorer, open the folder with the Markdown files.
  2. Click the address bar, type powershell and press Enter.
  3. Paste this command and press Enter:
$files = Get-ChildItem -Filter *.md | Where-Object Name -ne "combined.md" | Sort-Object Name
$parts = foreach ($file in $files) {
    "Source file: " + $file.Name + "`n`n" + (Get-Content -LiteralPath $file.FullName -Raw -Encoding utf8)
}
$text = $parts -join "`n`n---`n`n"
[System.IO.File]::WriteAllText("$PWD\combined.md", $text, (New-Object System.Text.UTF8Encoding $false))

The result is combined.md in the same folder. The documents follow each other in alphabetical order. Each one starts with a line such as Source file: annual-report.md, and a horizontal line separates it from the previous document.

Keep the UTF-8 settings in the command: without them, Windows PowerShell can garble accented and non-Latin letters.

To choose the order, put a number at the start of the Markdown file names, such as 01-contract.md, before you run the command. If you run the command again, combined.md is replaced and is not read as one of the documents.

Join only some of the files

To join part of a folder, change the filter in the first line. For example, to take only the files whose names start with 2026-:

$files = Get-ChildItem -Filter "2026-*.md" | Sort-Object Name

Use the rest of the command as it is. If you build several combined files in one folder, give each its own name by changing combined.md in the command.

What the combined file looks like

Source file: contract.md

# Supplier contract

...

---

Source file: handbook.md

# Team handbook

The text of each document is unchanged. Only the source line and the separator are new.

Pictures in the combined file

The pictures of each document are in a folder next to its Markdown file, and the links in combined.md point to those folders. Keep combined.md in the same folder as the images folders. If you move it, move the images folders with it.

The command joins the files of one folder. For documents in subfolders, run it in each subfolder, so every combined file stays next to its own images.

Check the combined file

Count the source lines. This command prints the number of documents in the file, which should equal the number of Markdown files:

(Select-String -Path combined.md -Pattern "^Source file: " -Encoding utf8).Count

Then look at the file itself:

  • Open combined.md and scroll to the boundary between two documents. The separator and the source line should sit between them.
  • Each document keeps its own headings, so the file has several top-level headings. The source lines show where each document starts.
  • If an AI tool rejects the file as too long, split the set into two folders and combine each.

Open or upload the result

Notepad opens combined.md, and so does Visual Studio Code, which can also show it formatted: press Ctrl+Shift+V. Other apps are listed in what an MD file is and how to open it. If an upload form does not accept .md files, upload a copy renamed to combined.txt.

To list the documents at the top of the file, print the source lines and paste them in:

Select-String -Path combined.md -Pattern "^Source file: " -Encoding utf8 | ForEach-Object Line

Tell the AI how the file is built

A tool that reads combined.md works better when it knows how the file is built. A short instruction at the start of the prompt is enough:

Read combined.md. Each document starts with a line
"Source file: name", and a horizontal line ends the
previous document. When you answer, name the source
file you used.

Check a few of the answers against the named files. The name only helps if it is right.

When a document changes

combined.md is a copy and does not follow the documents. Add the changed document to MD Factory again, then run the command again.

The combined file holds the text of every document, so treat it with the same care as the originals. If the folder syncs to the cloud, the file syncs too: see how to convert documents without uploading them.

Questions

Can MD Factory join the documents itself?

No. It saves one Markdown file for each document.

Does the command work in PowerShell 7?

It runs in Windows PowerShell and in PowerShell 7.