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

os.path.getmtime

The timestamp that actually means 'when was this edited'

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

Of the three timestamp nodes in this pack, mtime is the one you'll actually want 90% of the time. os.path.getmtime returns the time a file's contents were last modified - the plain-English "when was this edited" - which is what you mean when you say "did that output get regenerated?"

It's a thin wrapper from the ovum/path/os.path family in comfy-ovum, sfinktah's utility grab-bag. Every node in that family is a one-to-one mirror of a Python stdlib os.path function, so there's no behavior to learn: this is literally os.path.getmtime() exposed as a Comfy node. If you know the Python, you know the node.

How it works

The node reads the file's modification time at execution time and hands it back as a FLOAT (mtime) - seconds since the Unix epoch, exactly what Python returns. It takes the path from either:

  • path (STRING, required): the widget, type a path in directly.
  • path_in (PATHLIKE,STRING, optional): a link-only jack. Wire a string or a PATHLIKE (from the pack's "STRING to PATHLIKE (PurePath)" node) and it overrides the widget.

Output is a single FLOAT. That's the whole node.

Where it fits in a workflow

The classic use is freshness checks in automation-style graphs: you have a job that regenerates a file, and you want a downstream branch to run only if the file is newer than some threshold. Read mtime, compare against "now" (or against a stored earlier mtime - comfy-ovum's Set/Get environment-variable nodes make a decent two-run memory), and let a compare node drive the branch. It also pairs naturally with os.path.getsize: mtime tells you the file changed, size tells you how it changed.

Installing it

Same as every node in this pack - once per pack:

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

or search "comfy-ovum" in ComfyUI Manager. Restart after installing. No models to download; these path nodes need nothing beyond the Python stdlib, so no extra pip installs are involved.

Gotchas

  • The path must exist. Unlike the is* predicates, getmtime raises FileNotFoundError on a missing file and there's no try/except in the node - your run will fail loudly. Gate with os.path.isfile if the file might not be there yet.
  • The FLOAT is a Unix-epoch timestamp. ComfyUI won't format it for you; if you want a readable date, run it through the pack's Python String Format node with something like {arg0:.0f} and let a separate formatter deal with the epoch math.

The sibling nodes are worth knowing about: os.path.getctime is the "metadata/creation" timestamp, useful for change-watching but with platform quirks. os.path.getsize gives you the byte count. For "is this file done and when did it last change," mtime is the one to reach for.

Categoryovum/path/os.path

Inputs (2)

NameTypeDefaultDescription
pathSTRING
path_inoptPATHLIKE,STRING

Outputs (1)

NameTypeDescription
mtimeFLOAT