Nodes/ComfyUI_EmAySee_CustomNodes/EmAySee Filename Trigger Parser
ComfyUI Node

EmAySee Filename Trigger Parser

Turn coded filenames into prompt triggers — 'img_02_v1.png' becomes 'young adult'

By EmAySee·Created about a year ago·Updated 4 months ago· 2
EmAySee Filename Trigger Parser
    • trigger
    filename
    separator_
    target_index1
    map_1_code01
    map_1_valueteen
    map_2_code02
    map_2_valueyoung adult
    map_3_code03
    map_3_valuewoman
    map_4_code
    map_4_value
    map_5_code
    map_5_value
    fallback_value

    Here's the workflow this node exists for: you batch-generate images, and you've agreed that the filename encodes something about the image - girl_01_poseA, man_02_poseB, whatever your convention is. Now you want to feed that code back into the graph as a text value, because the next stage's prompt depends on it. This node splits the filename on a separator, pulls out the segment you care about, and maps it through a code→value table you define. 01 becomes teen, 02 becomes young adult. Filename convention in, useful text out.

    How it works

    It takes the filename, strips the extension and any directory path (so O:/outputs/img_01_v2.png and img_01_v2.png both work), splits the base name on separator (default _), and grabs the segment at target_index. That code is then looked up in up to five code→value mappings - map_1_codemap_1_value, and so on through map_5. If the code matches a mapping, you get the mapped value; if it doesn't match (or the mapping's value is empty), you get fallback_value.

    Two details from the source worth knowing:

    • target_index is zero-based in the code. The default is 1, which means the second segment (img_01_v2 splits into img, 01, v2; index 1 = 01). If your codes are the first segment, set it to 0.
    • Empty mappings are inert. A blank map_4_code/map_4_value pair simply never matches, so the defaults leave slots 4 and 5 unused without breaking anything.

    Inputs and outputs

    • filename (STRING, forced input) - wire it from a Load Image's filename output or a Save Image's file path.
    • separator (STRING, default _)
    • target_index (INT, 0–10, default 1) - which segment holds the code.
    • map_1_code/map_1_valuemap_5_code/map_5_value - your lookup table.
    • fallback_value (STRING, default empty) - returned when nothing matches.

    Output: trigger, a STRING. Feed it into a prompt template, a selector, or downstream logic - e.g., concatenate it into a CLIP text encode so the next stage's prompt conditionally mentions the attribute the filename encoded.

    Install

    Part of ComfyUI_EmAySee_CustomNodes. ComfyUI Manager → search "EmAySee" → install, restart, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/EmAySee/ComfyUI_EmAySee_CustomNodes
    

    No dependencies, no models. Restart and you'll see the pack's "SPECTRE v5.0" banner.

    The honest take

    It's a focused little tool and it's genuinely useful once you adopt a filename convention - but the convention is the hard part, not the node. Your filenames have to actually be consistent for this to work, and a single non-conforming name silently falls through to fallback_value. The five-slot mapping table is enough for most attribute sets (age, pose, style), but if you need more codes, you'll either chain two of these or move to a lookup file. The defaults (01teen, 02young adult, 03woman) are clearly the author's own tagging scheme - replace them with yours before first use.

    CategoryEmAySee/Text

    Inputs (14)

    NameTypeDefaultDescription
    filenameSTRING
    separatorSTRING_
    target_indexINT10–10
    map_1_codeSTRING01
    map_1_valueSTRINGteen
    map_2_codeSTRING02
    map_2_valueSTRINGyoung adult
    map_3_codeSTRING03
    map_3_valueSTRINGwoman
    map_4_codeSTRING
    map_4_valueSTRING
    map_5_codeSTRING
    map_5_valueSTRING
    fallback_valueSTRING

    Outputs (1)

    NameTypeDescription
    triggerSTRING