Nodes/ComfyUI-YogurtNodes/Glob Files (Yogurt Nodes)
ComfyUI Node

Glob Files (Yogurt Nodes)

Feed a whole folder of images into ComfyUI without typing paths by hand

By yogurt7771·Created 2 years ago·Updated 4 days ago· 1
Glob Files (Yogurt Nodes)
    • file_paths
    root_directory
    glob_pattern*
    sort_filesfalse
    sort_reversefalse
    glob_modeglob
    files_onlyfalse
    as_posixfalse
    full_pathfalse
    resolve_pathfalse
    prefix_list
    suffix_list
    extension_list
    extension_is_imagefalse
    relativefalse

    There's a moment in every batch workflow where you realize you're about to wire the same image path into twelve nodes by hand. Glob Files is the "no thanks" button for that. Point it at a folder, give it a pattern, and it returns a LIST of matching file paths - which you can then index, slice, or feed into whatever loader the rest of your graph uses.

    It's one of the I/O nodes in the YogurtNodes pack (yogurt7771/ComfyUI-YogurtNodes), and it's the piece that turns "I have 300 renders" into "I have a list I can loop over." Think of it as a poor man's batch scheduler: grab every *.png, sort them, walk them one at a time.

    How it works

    Under the hood it's Python's pathlib glob - the same pattern syntax you already know from the terminal. *.txt matches files in the root, **/*.py recurses into subfolders. You get a glob_mode toggle: glob walks left-to-right from the root, rglob walks right-to-left (useful when your pattern anchors on the filename and you want it matched against every directory level). The output is a single file_paths LIST.

    The genuinely useful part is the filtering, which saves you from writing clever patterns at all:

    • files_only - drop directories, keep files.
    • extension_list - "txt,py,json" keeps only those, case-insensitive. Set extension_is_image and it treats the list as image extensions.
    • prefix_list / suffix_list - comma-separated name filters like pre-1,pre-2.
    • sort_files + sort_reverse - alphabetical order, ascending or descending. Leave sorting off and you get whatever order the filesystem gives you, which will not be the order you want.

    Inputs that matter

    • root_directory - where to start. If you leave it empty you'll glob relative to ComfyUI's working directory, which is almost never what you meant.
    • glob_pattern - multiline, one pattern per line; empty lines are ignored. The default * is fine for a flat folder.
    • extension_list - the filter you'll reach for most. "png,jpg,jpeg" and done.

    The path-flavored toggles (as_posix, full_path, resolve_path, relative) mostly matter when you're on Windows or handing paths to other tools. as_posix swaps backslashes for /; resolve_path makes paths absolute and chases symlinks; relative returns paths relative to root_directory instead of absolute.

    Output: file_paths - a LIST. Wire it to a ListIndex or a loop, or pair it with ListConcat / ListBinaryOps to merge a few globs into one batch.

    Install

    YogurtNodes is one clone away - via ComfyUI Manager (search "YogurtNodes") or:

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

    Then restart ComfyUI; the node lives under Yogurt Nodes / IO. No models, no API keys, nothing heavy - this one's pure Python.

    Troubleshooting

    The common complaints, in order of how often I see them:

    • "It returned nothing." Check root_directory actually exists and the pattern matches - a * with files_only on a folder of only-directories gives you an empty list, by design. And remember glob_pattern is multiline: a stray empty line is ignored, but a pattern with a typo just matches nothing.
    • Recursion. If you want files in subfolders you need ** in the pattern (**/*.png) or rglob mode. Plain *.png only looks in the root.
    • Windows path confusion. Backslash-heavy absolute paths are a classic gotcha when you hand the output to other nodes. Flip as_posix on if a downstream tool chokes.
    • Batch order isn't "natural". With sort_files off, filenames can come back in filesystem order, which for numbered files means 1.png, 10.png, 2.png. If order matters, turn on sort_files - or sort numerically downstream with a list sort node.
    CategoryYogurtNodes/IO

    Inputs (14)

    NameTypeDefaultDescription
    root_directorySTRINGRoot directory path, from which to start searching for files.
    glob_patternSTRING*One glob pattern per line, e.g. '*.txt' or '**/*.py'. Empty lines are ignored.
    sort_filesBOOLEANfalseSort the file paths in alphabetical order.
    sort_reverseBOOLEANfalseSort in descending order.
    glob_modeCOMBOglobglob from left to right, rglob from right to left
    files_onlyBOOLEANfalseReturn only files, exclude directories.
    as_posixBOOLEANfalseConvert the path to a POSIX format.
    full_pathBOOLEANfalseReturn an absolute version of this path by prepending the current working directory. No normalization or symlink resolution is performed.
    resolve_pathBOOLEANfalseMake the path absolute, resolving all symlinks on the way and also normalizing it.
    prefix_listSTRINGPrefix list, multiple prefixes separated by commas, e.g. 'pre-1,pre-2,pre-3' etc. Case insensitive. If empty, all files will be returned.
    suffix_listSTRINGSuffix list, multiple suffixes separated by commas, e.g. 'txt,py,json' etc. Case insensitive. If empty, all files will be returned.
    extension_listSTRINGExtension list, multiple extensions separated by commas, e.g. 'txt,py,json' etc. Case insensitive. If empty, all files will be returned.
    extension_is_imageBOOLEANfalseIf true, the extension list will be treated as image extensions.
    relativeBOOLEANfalseReturn paths relative to the root directory.

    Outputs (1)

    NameTypeDescription
    file_pathsLIST