# Folder path mapping (ReplaceFolders)
The ReplaceFolders setting is available in all migration connectors. It controls how source folder paths are transformed into SharePoint target folder paths before a document is uploaded.
# Syntax
Rules are written one per line (or semicolon-separated on a single line). Each rule has the form:
SourcePath=TargetPath
SourcePath— the source path to match (case-insensitive, leading/trailing slashes ignored)TargetPath— the replacement path. Leave empty to strip the path:SourcePath=- Both
/and\are accepted as path separators
Multiple rules:
Clients\Archived=Archive
Clients\Active=Matters
Or equivalently on one line:
Clients\Archived=Archive;Clients\Active=Matters
# Matching rules
# 1 — Exact match
If the source path exactly equals a rule key, the rule value is returned as-is.
| Rule | Input | Result |
|---|---|---|
Contracts=Docs | Contracts | Docs |
Contracts=Docs | Contracts\NDA | Docs\NDA (prefix match, see below) |
# 2 — Prefix match (longest wins)
If no exact match is found, the connector tries each prefix from longest to shortest. When a matching prefix is found, it is replaced and the remaining path is appended.
Rules are always evaluated longest-first regardless of the order they are written.
| Rules | Input | Result |
|---|---|---|
A=B | A\X\Y | B\X\Y |
A\B=C | A\B\X | C\X |
A=B and A\B=C | A\B\X | C\X (longer prefix wins) |
A=B and A\B\C\D=D | A\B\C\D\E | D\E (most specific prefix wins) |
# 3 — Catch-all (empty key)
A rule with an empty left-hand side (=Target) matches any path that has no other rule. The target is prepended to the original path.
| Rule | Input | Result |
|---|---|---|
=Inbox | Letters | Inbox\Letters |
=Inbox | Archive\2023 | Inbox\Archive\2023 |
A=B and =Inbox | A | B (exact match takes priority) |
A=B and =Inbox | Other | Inbox\Other (catch-all applies) |
# 4 — Strip prefix
A rule with no value on the right side strips the matched prefix from the path.
| Rule | Input | Result |
|---|---|---|
\\server\share\clients= | \\server\share\clients\Matter1 | Matter1 |
\\server\share\clients= | \\server\share\clients | (empty — document library root) |
# 5 — __SKIP__ (exclude documents)
Setting the target to __SKIP__ causes the connector to skip all documents whose resolved path starts with that key. The document is excluded from the migration entirely.
| Rule | Input | Result |
|---|---|---|
Templates=__SKIP__ | Templates | skipped |
Templates=__SKIP__ | Templates\Master | skipped |
=__SKIP__ | any unmapped path | all unmapped documents skipped |
Combining __SKIP__ with explicit rules
Use =__SKIP__ as a catch-all to skip everything that is not explicitly mapped. Only paths with an explicit rule will be migrated.
Contracts=Contracts
Correspondence=Correspondence
=__SKIP__
In this example, only documents in Contracts or Correspondence are migrated. Everything else is skipped.
# 6 — __ROOT__ (map empty path)
__ROOT__ as a key matches documents whose source path is empty or null (i.e., documents at the root of the source location with no subfolder). Without this rule, root documents are placed at the document library root in SharePoint.
| Rule | Input | Result |
|---|---|---|
__ROOT__=General | (empty path) | General |
__ROOT__=General | Contracts | Contracts (no effect on non-empty paths) |
Difference between `__ROOT__` and the empty-key catch-all
__ROOT__=Targetonly matches an empty or null source path. Other unmapped paths are returned unchanged.=Target(empty key) matches any path that has no rule, including non-empty ones.
They can be combined:
__ROOT__=General
=Archive
- Empty path →
General - Any other unmapped path →
Archive\{original path}
# Practical examples
# Directory import: rename subfolders
For directory-based imports, the manifest row specifies SourceDirectory (the full UNC path to the matter folder). The connector strips the SourceDirectory prefix and passes only the relative subfolder path to ReplaceFolders. The UNC path is never seen by ReplaceFolders.
For example, given:
SourceDirectory = \\fileserver\clients\Matter1- A file at
\\fileserver\clients\Matter1\Old Contracts\NDA.docx
The relative path passed to ReplaceFolders is Old Contracts. A rule targeting the UNC path would have no effect.
Old Contracts=Contracts
Old Correspondence=Correspondence
Old Contracts\NDA.docx→Contracts\NDA.docxOld Correspondence\Letter.msg→Correspondence\Letter.msgInvoices\2023.pdf→Invoices\2023.pdf(no rule — unchanged)
# Rename a folder at any level
Archived=Archive
Archived→ArchiveCorrespondence\Archived→Correspondence\Archive(prefix match)
# Reorganize top-level folders
Legal\Contracts=Contracts
Legal\Correspondence=Correspondence
Legal\Internal=__SKIP__
Legal\Contracts\NDA.docx→Contracts\NDA.docxLegal\Correspondence\Letter.msg→Correspondence\Letter.msgLegal\Internal\Notes.docx→ skippedLegal\Other\Doc.docx→Legal\Other\Doc.docx(no rule, unchanged)
# Migrate only specific folders, skip everything else
Contracts=Contracts
Correspondence=Correspondence
=__SKIP__
Only Contracts and Correspondence are migrated. All other paths are skipped.
# Route root documents to a specific folder
__ROOT__=General
Documents with no source subfolder land in General instead of the document library root.
# Notes
- Matching is case-insensitive
- Rules are always applied longest-prefix-first regardless of the order they are written
- If no rule matches and there is no catch-all, the source path is used as-is
- Path separators (
/and\) are normalized to\internally; use either in rules