Nodes/comfy-ovum/os.path.normcase
ComfyUI Node

os.path.normcase

Making 'c:\Models' and 'C:\models' compare equal

By sfinktah·Created about a year ago·Updated 10 months ago· 7
os.path.normcase
  • path_in
  • path
path
forward_slashesfalse

Here's a bug that'll burn an afternoon: your workflow compares a path from a widget against a path from a loader, they look identical, and the comparison says they're different - because one is C:\Models\v1 and the other is c:\models\v1. On a case-insensitive filesystem those are the same file, but string comparison doesn't know that. os.path.normcase normalizes path case (and, on Windows, separator style) so that "same path, different casing" compares equal.

It's from the ovum/path/os.path family in comfy-ovum, a thin wrapper over Python's os.path.normcase(). Its behavior is exactly the stdlib's - which is platform-specific, and that's the whole point.

How it works

Takes a path, normalizes it, returns a STRING (path). Inputs:

  • path (STRING, required): the widget.
  • forward_slashes (BOOLEAN, required, default false): on top of the case normalization, convert backslashes to forward slashes in the result.
  • path_in (PATHLIKE,STRING, optional): link-only; overrides the widget when connected.

One STRING out.

What normalization means depends on your OS, because that's what normcase does:

  • Windows: lowercases everything and converts / to \. C:\Models\V1c:\models\v1. This is the case where it does real work.
  • Linux/macOS: on POSIX it's essentially a no-op - case matters on these filesystems, so the stdlib leaves it alone (macOS can be slightly less no-op-ish in some Python versions, but effectively it passes through).

Where you'd use it

The canonical pattern is path-equality checks in routing logic: when you need to know "is this output path the same as that one?" run both sides through normcase first, then compare. It's also useful before os.path.join or a saver when you want to guarantee a consistent, comparable form for every path entering your graph - especially in workflows that merge paths from multiple sources (widgets, loaders, environment variables) where casing drifts.

The forward_slashes toggle is a bonus you won't find in plain Python: it lets you force /-separated output even while normcase lowercases, which is handy when the downstream consumer is picky about separator style.

Installing it

Pack-wide, once:

cd ComfyUI/custom_nodes
git clone https://github.com/sfinktah/comfy-ovum

Or ComfyUI Manager → "comfy-ovum" → Install → restart. No models, no extra deps.

Gotchas

  • Don't expect magic on Linux. If you're on a case-sensitive filesystem, normcase changes nothing - and it shouldn't, because Models and models genuinely are different paths there. If you want case-insensitive comparison on Linux (say, comparing Windows-style paths on a Linux box), normcase won't do it for you; you'd need a manual .lower() via a string utility instead.
  • It's normalization, not existence checking. A path that doesn't exist normalizes just fine.
  • The stdlib's Windows behavior converts / to \ - so if you also toggle forward_slashes, the order of operations is worth knowing: you get backslashes back unless the toggle is on, in which case they get converted again on the way out. Leave the toggle off unless you specifically need / output.

If you've ever shipped a workflow that misbehaved on one Windows machine but not another because of a capital C: in a path, this node is the reason that stops happening.

Categoryovum/path/os.path

Inputs (3)

NameTypeDefaultDescription
pathSTRING
forward_slashesBOOLEANfalse
path_inoptPATHLIKE,STRING

Outputs (1)

NameTypeDescription
pathSTRING