Nodes/ComfyUI-GU_Nodepack/GU Get Media Input Name
ComfyUI Node

GU Get Media Input Name

Turn 'whatever image you just loaded' into an actual filename

By alexguryev·Created 4 months ago·Updated 23 days ago· 2
GU Get Media Input Name
  • any
  • filename
strip_exttrue

The name says it all, and it solves a genuinely annoying problem: you loaded an image (or a video, or an audio file) from a loader, and now you want the filename - without typing it and without re-typing it when you change the file. GU Get Media Input Name grabs the filename from the upstream loader and hands it to you as a string you can feed into a filename builder, a save node, or a text label.

It's a "dumb" node in the best sense: one wildcard input, one string output, no configuration beyond a toggle. But what happens under the hood is sneakier than it looks.

What it does

  • any - a wildcard (*) input. Connect it to any loader's output: Load Image, Load Video, Load Audio, whatever. The node doesn't care about the type; it cares about where the data came from.
  • strip_ext - default on. Returns the filename without the extension. Flip it off and you get frame_0012.png instead of frame_0012.

Output: filename, a STRING - the base name of the media file, with or without extension depending on the toggle.

The mechanism worth knowing about

Because you connect it to any output, the node can't just read a widget. Instead it works backward through the graph: it inspects the prompt/extra_pnginfo metadata for the connected node, then walks the wire upstream, skipping reroute nodes as it goes, until it finds the actual loader and reads the filename widget from it. That's why "reroutes are handled" in the README - you can thread this through a tangle of reroutes and it still finds the source.

Also note: the node always executes when the Queue runs. That's the IS_CHANGED returning NaN trick - it deliberately defeats ComfyUI's execution cache so it fires every run. That's required here (you don't want a stale filename), but it also means the node sits outside the cache, which is worth knowing if you're debugging why a graph re-executes more than you expected. See the plumbing essay on this in the KB: NaN is "not equal to anything, even another NaN," so the node is always dirty.

The one real gotcha

The README warns: there may be ordering issues when several such nodes exist in the same graph. Because it works by tracing the graph's metadata, multiple G_GetMediaInName nodes in one workflow can trip over each other depending on execution order. If you're using more than one, keep them in separate, clean branches rather than chaining them, and if the filename comes back as !unknown!, that's the node telling you it couldn't trace the source - check that the upstream is actually a media loader and not a passthrough node with no filename widget.

Install

ComfyUI Manager → Custom Nodes Manager → search "GU Nodepack" → Install → restart, or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/alexguryev/ComfyUI-GU_Nodepack
cd ComfyUI-GU_Nodepack
pip install -r requirements.txt

Deps are just psutil, requests, gu-funclib>=1.9.0. No model files to download. Windows-tested; the pack is a single-user design and warns about race conditions on multi-user servers - this filename-tracing node is exactly the kind of thing that could behave oddly under those conditions.

CategoryGU_Nodepack

Inputs (2)

NameTypeDefaultDescription
anyopt*
strip_extoptBOOLEANtrue

Outputs (1)

NameTypeDescription
filenameSTRING