Get Clean Filename
Pull just the name out of a full file path
- STRING
You've got a full path - /some/long/folder/structure/my_render_00042.png - and you want just my_render_00042 out of it. Get Clean Filename does exactly that: hand it a path, get back the bare filename, stripped of the directory in front and (as the name implies) cleaned up. It's a string-wrangling helper for the moments where a path is flowing through your graph but what you actually want to reuse is the name - to build an output filename, stamp it into metadata, or match it against something.
This kind of node is invisible until you need it, and then it's exactly right. Video and media workflows especially throw paths around: you load a clip from a path, do work, and want to save the result named after the source. Rather than carry the whole ugly path forward, you extract the clean name and build from there.
How it works
Straight path parsing. It takes the path string, drops everything up to and including the last directory separator, and returns the filename portion. The "clean" part means it hands back a tidy name suitable for reuse rather than a raw path fragment. No files are read or touched - this is pure string manipulation, so it works whether or not the path actually points at something that exists.
The inputs and outputs that matter
file_path- the full path string to extract from. Single-line. Typically wired from a media loader's path output or another node that produces a path.
The output is a single STRING - the clean filename - ready to feed a save node's filename input, a metadata writer, or a search-and-replace.
How to install it
ComfyUI Manager, search JNodes, install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/JaredTherriault/ComfyUI-JNodes
pip install -r ComfyUI-JNodes/requirements.txt
No models.
Common issues & troubleshooting
It kept (or dropped) the extension and I wanted the opposite. Check what actually came out before building on it - extension handling is the usual surprise with filename nodes. If the result isn't shaped how you need, a quick search-and-replace (the pack has nodes for it) fixes the suffix.
Empty output. The input path was empty or didn't contain a separator the parser recognizes. Confirm you're feeding a real path string, not an empty widget.
Mixed slashes across OSes. Windows paths use backslashes, Unix uses forward slashes. If a path came from a different system than the one you're running on, the separator style can trip up naive parsing - normalize the slashes upstream if you're moving paths between platforms.
It's just string work - no file needed. Worth repeating: this doesn't verify the file exists. It parses text. A path to a file that isn't there still returns a clean name; if you needed to confirm the file is real, that's a different check.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| file_path | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |