Nodes/Arkl1te's Toolkit/GetNewFileIndex
ComfyUI Node

GetNewFileIndex

The old name for Count Files In Directory (it's literally the same node)

By arkl1te·Created 11 months ago·Updated 10 months ago· 1
GetNewFileIndex
    • INT
    directoryvideo
    extensionmp4

    You probably got here from an old workflow file, so let's not waste words: GetNewFileIndex is the previous name of Count Files In Directory. Same class, same code, same behavior - the pack registers both names in its node mapping, so any saved workflow that references the old name still loads and runs without you hunting down a replacement. There is no reason to add this node yourself; the only reason you'd ever see it is legacy.

    Why the rename? The old name oversold what the node does. "Get New File Index" implies it computes the next available number for a new file. It doesn't - it just counts files that already exist in a directory and returns that count as an INT. The author renamed it to Count Files In Directory precisely because the count is the honest description, and the "new index" is something you derive from it (usually count + 1). Renames like this are increasingly common in the ComfyUI ecosystem as packs get cleaned up; keeping the alias is the considerate part, because it means shared workflows don't rot the moment a node changes names.

    The mechanism is identical to its sibling article, so the short version: directory defaults to video and resolves relative to ComfyUI's output folder; extension defaults to mp4 and matches case-insensitively; it returns 0 if the folder doesn't exist; and it sets IS_CHANGED to a random value so it re-runs every time and never serves you a stale count. Both inputs are plain STRING fields, and directory comes with a browse button. Output is one INT.

    Where it lands in a workflow: it feeds the batch-naming chain - count existing clips → zero-pad the number with Pad Zeroes → assemble a filename with Concatenate → hand video_0007.mp4 to Save Video. That chain is the whole reason these nodes exist, and it's built for video batches specifically (LTX/Wan style pipelines that dump clips into output/video).

    Two traps worth stating plainly. First, a count is not a reservation: delete a file from the folder and the number drops, so you can still collide with an existing filename. Second, it only counts files directly in the folder - no recursion, no subfolders, and it can't see arbitrary absolute paths, only output-relative ones. For an output folder that only ever grows, count + 1 is a safe index; anything fancier needs real logic.

    Install is identical to the rest of the pack. ComfyUI Manager, search "Arkl1te's Toolkit", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cybernaut4/comfyui_arkl1te_toolkit
    

    Restart ComfyUI. There's no requirements.txt and no model download - the pack declares zero dependencies, so nothing to pip-install and nothing to conflict with your other custom nodes. And if you're building a new workflow from scratch, add Count Files In Directory from the menu instead of this one. Use the new name; just know the old one still works if you ever load a workflow that insists on it.

    CategoryArkl1te's Toolkit/int

    Inputs (2)

    NameTypeDefaultDescription
    directorySTRINGvideo
    extensionSTRINGmp4

    Outputs (1)

    NameTypeDescription
    INTINT