Nodes/SP-Nodes/SP_CacheDirToKeys
ComfyUI Node

SP_CacheDirToKeys

Replay every saved video from a folder, without recomputing a frame

By bananasss00·Created 2 years ago·Updated 13 days ago· 24
SP_CacheDirToKeys
    • keys_list
    directory_pathoutput/selected
    file_extension.mp4

    SP_CacheDirToKeys turns a folder of rendered files into a list of cache keys - and because that list comes out as a batch, ComfyUI runs the rest of your graph once per key. This is the "replay my saved jobs" node of the cache suite.

    Here's the workflow it's built for. You render a batch of videos to output/selected. Each render gets cached under its job name by the pack's cache loaders. Later - same session or after a restart - you drop this node in, point it at that folder, and wire its keys_list into the cache lookups downstream. ComfyUI sees a list output and batch-executes the whole graph for each key in turn. Every job that's already cached hits the memory/disk tiers and skips rendering; only genuinely new or changed jobs recompute. You get an overnight-batch pattern: render once, then cheaply re-run composites or analysis over the results forever.

    How it works

    get_keys scans directory_path for files matching file_extension (default .mp4, * for everything), and applies the same cleanup the rest of the cache uses on each name: strip the extension, strip a trailing ComfyUI _00001-style counter, strip a _multi suffix, and dedupe. The output is declared OUTPUT_IS_LIST, and the source comment is refreshingly honest about it: "this magic turns the node into a batch generator for the entire graph."

    Relative paths are resolved against ComfyUI's working directory, and if the folder doesn't exist it logs an error and returns an empty list rather than crashing.

    The inputs that matter

    • directory_path - the folder to scan, default output/selected.
    • file_extension - the filter, default .mp4; use * for all files.

    Output is a single keys_list of strings.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/bananasss00/ComfyUI-SP-Nodes
    

    restart, or install "SP-Nodes" via ComfyUI Manager. No extra dependencies for this node - it's os.listdir and a regex.

    Where people get burned

    The folder must exist; an empty or missing folder yields zero keys and the batch silently does nothing. And the cleanup assumes names came out of ComfyUI's render pipeline - if your files don't have standard _00001 counters, the keys it produces won't match the ones your loaders wrote, and every lookup misses. Check the actual .joblib filenames in the cache folder if replays aren't hitting.

    CategorySP-Nodes/cache/utils

    Inputs (2)

    NameTypeDefaultDescription
    directory_pathSTRINGoutput/selectedFolder with your sorted/selected videos.
    file_extensionSTRING.mp4Filter by extension. Use '*' for all files.

    Outputs (1)

    NameTypeDescription
    keys_listSTRING