Filename Extractor
Strip a full path down to the bare filename
- extracted_name
- pattern_found
- full_filename
Extract Filename is exactly what it sounds like: feed it a file path, get back the filename without the extension. D:\folder\file.jpg becomes file. That's the whole job, and honestly that's the whole point - it's a tiny string utility that saves you from hand-typing names in workflows that build output paths or labels.
What it does
One input, file_path (STRING), one output, filename (STRING). Paste in a path, or wire it from something that produces one - this pack also ships Load Image (with filename), which hands you the filename of an uploaded image, and that's the natural pairing. From there you can feed the name into a text node, a save path, a filename-prefix builder, or anywhere else a bare name is more useful than a full path.
How it works
It's two Python stdlib calls under the hood: os.path.basename() to strip everything before the last path separator, then os.path.splitext() to cut the extension. No filesystem access, no I/O, no state - pure string in, string out. That means it works on paths that don't even exist yet, which is handy for planning output names before a node has saved anything.
The one gotcha
The implementation uses os.path, and path-separator handling follows the OS ComfyUI is running on. On Windows, backslash paths work as in the docstring example. On Linux or macOS, a Windows-style D:\folder\file.jpg won't split on the backslashes, because Python only treats / as the separator there. If you're on Linux and passing Windows-style paths, convert them to forward slashes first - most ComfyUI nodes hand you forward-slash paths anyway, so in practice this rarely bites. It's worth knowing before you copy-paste a Windows path and stare at a filename that never shrinks.
Installation
This is one of 17-odd nodes in Praveen's ComfyUI Tools. Install via ComfyUI Manager (search "Praveen" or "praveen-tools"), or:
cd ComfyUI/custom_nodes
git clone https://github.com/Praveenhalder/praveen-tools
Restart ComfyUI after. The pack has no extra dependencies and no model downloads - the README's dependency list (PyTorch, Pillow, NumPy) is just what ComfyUI already ships.
Honest take: this is a three-line helper wearing a node costume. Don't expect more than that. But the moment you need a filename as text inside a workflow, it's the difference between a quick wire and hunting for a text-editor node that happens to strip paths. For that use case it's fine.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| filename | STRING | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| extracted_name | STRING | — |
| pattern_found | STRING | — |
| full_filename | STRING | — |