Nodes/ComfyUI_MieNodes/Get File Basename ๐Ÿ‘
ComfyUI Node

Get File Basename ๐Ÿ‘

Pull the filename out of a full path

By MieMieeeeeยทCreated 2 years agoยทUpdated 28 days agoยท 225
Get File Basename ๐Ÿ‘
    • basename
    โ—„file_pathinput/foo.mp4โ–บ

    Tiny, single-purpose, and exactly the kind of glue you end up needing at the worst possible moment. GetFileBasename takes a file path like input/videos/foo.mp4 and gives you back just foo.mp4 - the last part, without the directory in front of it. That's it. It exists because you'll hit a spot where you have a full path but a downstream node wants just the name, and without this you're stuck.

    Part of ComfyUI-MieNodes (ComfyUI_MieNodes), MieMieeeee's utility pack, under ๐Ÿ‘ Common.

    Why you'd reach for it

    String plumbing is the unglamorous half of any workflow that touches files. You load something by its full path, then you want to reuse just its name - to build an output filename that matches the input, to label a result, to key a cache, to feed a "save as" step so your export lands next to nothing weird. Doing that by hand means a string-manipulation node from some other pack; this bakes the one operation everyone actually needs into a node that does nothing else.

    It pairs naturally with the pack's other file utilities. You might list a folder with GetDirectoryFilesInfo, grab full details with GetFileInfo, and use this to peel the bare name off a path when you need to name an output after its source.

    How it works

    There's no magic here - it's the equivalent of os.path.basename. Given any path string, it strips everything up to and including the last slash and returns the final component. output/cache/render_042.png becomes render_042.png. It doesn't care whether the file exists; it's operating on the string, not the disk, so it works fine on a path you're about to create.

    The inputs and outputs that matter

    One input, one output, both STRING:

    • file_path (STRING) - the path to slice. Default is the placeholder input/foo.mp4.
    • basename (STRING, output) - the filename portion. Wire it wherever a node wants a name rather than a full path.

    That genuinely is the entire surface. It's a leaf utility; the value is that it's there when the graph needs it.

    Installing it

    ComfyUI Manager โ†’ search ComfyUI-MieNodes โ†’ install โ†’ restart. Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/MieMieeeee/ComfyUI-MieNodes
    

    then restart. No dependencies, no model. Nodes appear under ๐Ÿ‘ MieNodes.

    Common issues & troubleshooting

    It keeps the extension. basename returns foo.mp4, not foo. If you want the name without the extension - say, to build foo.txt from foo.mp4 - you'll need a further string step to trim the suffix; this node doesn't do that part.

    Mixed slashes. If you're pasting Windows paths with backslashes into a workflow that's running on Linux (as it would be on a cloud runner), the definition of "last separator" can surprise you. Stick to forward slashes in workflow strings and you'll avoid the edge case entirely.

    Nothing to display on its own. Like the rest of these small utilities it just transforms a string - there's no preview. Wire basename into a Show Any node if you want to eyeball what it produced.

    Category๐Ÿ‘ MieNodes/๐Ÿ‘ Common

    Inputs (1)

    NameTypeDefaultDescription
    file_pathSTRINGinput/foo.mp4โ€”

    Outputs (1)

    NameTypeDescription
    basenameSTRINGโ€”