How to Detect Case-Sensitive Filename Collisions Before a Cross-Platform Copy

Eva Wong is the Technical Writer and resident tinkerer at ZimaSpace. A lifelong geek with a passion for homelabs and open-source software, she specializes in translating complex technical concepts into accessible, hands-on guides. Eva believes that self-hosting should be fun, not intimidating. Through her tutorials, she empowers the community to demystify hardware setups, from building their first NAS to mastering Docker containers.

Detect case-sensitive filename collisions by inventorying every relative path, normalizing each path to the destination's comparison rules, and grouping paths that produce the same normalized key. Resolve every group before copying data.

This preflight is essential when moving from a case-sensitive Linux share to Windows, default macOS volumes, or case-insensitive SMB namespaces. A normal file count will not reveal that two valid source names compete for one destination name.

What Counts as a Filename Collision?

A collision occurs when distinct source paths are treated as the same path by the destination. A practical reminder about cross-platform case-sensitivity differences shows why Report.pdf and report.pdf may behave differently, but the comparison must include every directory component.

Cross-platform conflicts can also involve Unicode normalization, trailing spaces or periods, reserved device names, and characters that one destination forbids. The causes of filename changes between macOS and Linux belong in the same path-compatibility audit.

Define the target before scanning. A copy to ext4, NTFS, or an SMB-backed dataset can expose different naming behavior. This is related to why SMB behavior differs across clients.

Which Collision Types Should the Preflight Report?

Separate collision categories so the remediation is predictable. A case-only pair can usually be renamed, while a reserved Windows name may require both renaming and an application-reference update.

Collision type Example Why copying is unsafe
Case-only Photo.jpg and photo.jpg Case-insensitive destination sees one name
Directory-component case Client/A and client/A Whole subtrees can merge
Unicode normalization Visually identical composed and decomposed names macOS and network layers may normalize differently
Trimmed characters notes and notes. Some Windows paths ignore trailing periods or spaces
Reserved name CON.txt Destination API may refuse creation

The report should preserve the original byte-level path and display a readable form. Visually identical Unicode names can otherwise look like a duplicate line rather than two distinct source entries.

How Do You Build a Reliable Source Inventory?

Run the inventory on the source filesystem or through the same protocol used for migration. Export relative paths in a format that safely handles spaces, tabs, newlines, and non-ASCII characters.

Include directories because two colliding directory names can hide thousands of affected files. Record object type, size, modification time, and a stable identifier when available so renamed items can be traced.

Freeze writes or take a snapshot before the final scan. If names change between inventory and copy, a clean preflight can become stale before migration begins.

How Should Paths Be Normalized for Comparison?

Start with the destination's case-folding behavior. Compare a lowercase or case-folded key while retaining the original path for reporting. Do not rename the source automatically during this step.

Then add destination-specific rules: Unicode normalization, separator handling, forbidden characters, trimmed suffixes, path-length limits, and reserved names. Normalizing more aggressively than the destination can create false positives, while normalizing less can miss destructive collisions.

Apply normalization to every path component. Two files with different basenames still collide if their parent directories collapse to the same normalized path.

What Can You Run on Linux, macOS, or Windows?

On Linux or macOS, a script can read null-delimited paths, compute a destination key, sort by that key, and report groups with more than one original path. Published methods for finding duplicate filenames in any case illustrate the grouping logic, but mixed-language archives need explicit Unicode handling.

find /source -print0 | python3 collision_scan.py --target windows

On Windows, PowerShell can enumerate relative paths and group them using an ordinal case-insensitive comparer. Run it against the source share with an account that can see every intended directory.

Get-ChildItem -LiteralPath '\\NAS\Source' -Recurse -Force |
  ForEach-Object { $_.FullName.Substring($root.Length).ToLowerInvariant() } |
  Group-Object | Where-Object Count -gt 1

These examples illustrate the grouping model, not a universal scanner. Production checks must preserve originals, handle inaccessible paths, and implement the target's full naming rules.

How Should You Resolve Collision Groups?

Choose a canonical name with the data owner, then rename the other paths using a deterministic suffix such as a project code, date, or source-system tag. Consistent home server naming rules help avoid arbitrary suffixes.

  1. Export the collision group and its owning department or application.
  2. Select the path that keeps the canonical spelling.
  3. Rename conflicting paths on the source or in a staged copy.
  4. Update playlists, databases, shortcuts, scripts, and manifests that reference them.
  5. Rerun the complete scan until no blocking groups remain.

Do not allow the copy tool to decide silently by overwrite order. Even if both file contents are identical, silently collapsing names destroys evidence about the original namespace.

How Do You Verify the Copy Did Not Collapse Paths?

Capture a pre-copy manifest after remediation and generate a destination manifest with the same relative-path rules. Compare normalized path sets, object counts, sizes, and content hashes for critical files.

Review copy logs for “already exists,” rename, skip, invalid name, and overwrite events. A zero exit code may still accompany skipped paths depending on the tool.

Keep the source read-only until users validate application behavior. Namespace compatibility includes links and references, not just the presence of file bytes.

FAQ

Can two filenames that differ only by case exist on Linux?

Usually yes on common case-sensitive Linux filesystems. They may collide when copied to a case-insensitive destination or exposed through a differently configured service.

Is converting every filename to lowercase a safe fix?

No. Bulk lowercasing can create new collisions and break references. Detect groups first, then apply reviewed, deterministic renames.

Do checksums detect filename collisions?

Checksums compare content, not namespace identity. Two different paths can have different or identical content and still compete for one destination name.

A safe cross-platform copy proves that every source path maps to one unique, valid destination path. Perform that proof before transfer rather than discovering collisions through overwritten files.

Support & Tips

More to Read

Get More Builds Like This

Stay in the Loop

Get updates from Zima - new products, exclusive deals, and real builds from the community.

Stay in the Loop preferences

We respect your inbox. Unsubscribe anytime.