Nodes/APZmedia Naming Tools/APZmedia Cycle Int
ComfyUI Node

APZmedia Cycle Int

A counter that steps through a range so you never hand-edit a number between runs

By APZmedia·Created 2 years ago·Updated 5 months ago· 8
APZmedia Cycle Int
    • value
    min_value1
    max_value10
    step1
    direction

    Every batch job has that one number you bump between runs - the shot index, the version, the output folder index - and editing it by hand is how you get shot 12 saved twice and shot 13 never saved. APZmedia Cycle Int is the APZmedia Naming Tools node that automates exactly that: it outputs an integer that advances through a range every time the workflow runs, wraps around when it hits the end, and sits there quietly until you need it.

    The interface is four widgets: min_value, max_value, step, and direction (Increment or Decrement). One output: value (INT). That's the entire node, and it's deliberately boring.

    The behavior, straight from the source, is worth knowing precisely because the details decide whether your batch works:

    • First run returns the starting value - min_value if incrementing, max_value if decrementing - then advances on every subsequent run.
    • Step size is your call, with one subtlety worth knowing: the wrap is modular, so a step that doesn't divide the range evenly won't land you back at the start. A step of 3 over a 1–10 range actually cycles 1, 4, 7, 10, 3, 6, 9, 2, 5, 8 before repeating - it never leaves the range, but it's not the naive up-and-back you might expect. If you want a predictable 1, 2, 3… walk, keep step at 1.
    • Wrap-around happens cleanly on both ends, so a decrementing counter doesn't throw an error at the bottom, it jumps back to the top.
    • Each node instance has its own counter. Two Cycle Int nodes in the same graph are independent - no shared state to corrupt your batch.
    • It's a session counter, not a life commitment. Restart ComfyUI and every Cycle Int resets to its starting value.
    • If you change min/max mid-session and the current value falls outside the new range, it resets to the new starting point rather than doing anything dramatic. Swapped min/max (min greater than max) are even tolerated - the node just flips them.

    The implementation detail that makes it reliable is that the node forces a re-execute on every queue run (IS_CHANGED returns NaN), so the counter actually advances each time instead of being cached. That's the kind of thing a naive clone gets wrong.

    Where it shines: feed value into a filename builder for a sequence number, into APZmediaGenerateFilePath to cycle output folders, or into a save prefix so a batch of runs files itself as 001, 002, 003 without you touching anything. It pairs naturally with the rest of this pack, but it works just as well as a general "increment this thing" utility in any workflow. Keep your expectations calibrated - it will not survive a ComfyUI restart, so don't use it for anything that needs to be permanent, and don't expect it to persist across node instances.

    Install

    ComfyUI Manager → search "APZmedia Naming Tools". Or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/APZmedia/ComfyUI-APZmedia-cleanName-from-string
    cd ComfyUI-APZmedia-cleanName-from-string
    pip install -e .
    

    Restart, find it under APZmedia. Pure Python, no dependencies beyond the pack's tiny unidecode, no model downloads. It's the node that turns a manual batch chore into a set-and-forget queue run.

    CategoryAPZmedia

    Inputs (4)

    NameTypeDefaultDescription
    min_valueINT1-999999–999999
    max_valueINT10-999999–999999
    stepINT11–999999
    directionCOMBO2 options: Increment, Decrement

    Outputs (1)

    NameTypeDescription
    valueINT