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

os.path.basename

Grab the filename off a full path — os.path.basename as a node

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

Ovum Os Path Basename is a one-liner turned into a node: it takes a full path and returns the last component - the filename - stripping off everything before the final separator. C:\ComfyUI\output\render_00042.png becomes render_00042.png. That's the whole job, and it's exactly the job you keep needing when a saver or a path-building node hands you full paths but your logic wants just the name.

Think about where this slots in. You want to display the filename in a note or a log line. You want to match a file's basename against a regex or a wildcard. You're building a caption or a filename prefix from the last output file. Every one of those starts with "strip the directory off this path." This is the node that does it without a Python Script node.

It's one member of the pack's os.path wrapper family - same pattern as dirname (its inverse) and the rest: a path widget, an optional wired path_in, and a string out.

How it works

Straight pass-through to the Python standard library: os.path.basename(path). No existence check, no normalization beyond what the OS does - purely a string split on the path separator (and the trailing-slash rules, so C:\dir\ yields an empty basename, matching Python's behavior exactly). The node shares the family's _FirstArgPathBase base, so the path_in jack, when connected, overrides the widget.

The inputs and outputs that matter

  • path (required, STRING) - the full path.
  • path_in (optional, PATHLIKE,STRING) - wired alternative to the widget.
  • path (output, STRING) - just the basename.

Note this node has no forward_slashes toggle in its schema (unlike several siblings) - it returns the basename as-is.

Installing it

In comfy-ovum (sfinktah). ComfyUI Manager: search "comfy-ovum", install, restart. Or:

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

Restart after cloning. No models, no heavy dependencies - the pack's requirements are the usual light set and Manager installs them.

Common issues

The standard-library fidelity is the thing to remember: a path ending in a separator (C:\out\) returns an empty string, and a bare filename like render.png returns itself. There's no validation, so a garbage string produces a garbage (but still deterministic) basename. If you want the filename without its extension, pair this with the pack's OvumOsPathSplitext - basename keeps the extension, splitext splits it off.

Categoryovum/path/os.path

Inputs (2)

NameTypeDefaultDescription
pathSTRING
path_inoptPATHLIKE,STRING

Outputs (1)

NameTypeDescription
pathSTRING