Skip to content

Conversation

altoiddealer
Copy link

@altoiddealer altoiddealer commented Aug 24, 2025

Resolves #9503

Currently: %date:FORMAT% placeholders in fields like filename_prefix are only expanded when entered directly in the node UI. This works because the frontend handles the substitution before passing the value to the backend.

However, if the same string is piped in from another node (e.g. String, Combine Text, etc.), the placeholder is passed to the backend unchanged. Since the backend’s compute_vars function only supports a fixed set of tokens (%year%, %month%, %day%, etc.), %date:...% values are not resolved. This leads to incorrect or invalid filenames such as:

yyyy-MM-ddhhmmss_00001.png

or, on Windows, runtime errors like:

OSError: [Errno 22] Invalid argument: '...\\%date:yyyy-MM-dd%_%date:hhmmss%__00001.png'

Current

Fix

This PR adds backend support for %date:FORMAT%.

  • Introduces a regex-based handler for %date:...%

  • Maps common Java/ISO-style patterns (yyyy, MM, dd, hh, mm, ss) to Python’s strftime equivalents

  • Ensures consistent substitution regardless of the source of the format string

Result

With this change, both direct inputs and piped inputs produce correctly formatted filenames. For example:

Input:

WAN/%date:yyyy-MM-dd%%date:hhmmss%

Output:

WAN/2025-08-23_143752_00001.png

This makes datetime substitution consistent across all nodes and prevents invalid filenames.

Fixed

@ltdrdata ltdrdata added the Good PR This PR looks good to go, it needs comfy's final review. label Aug 25, 2025
@silveroxides
Copy link
Contributor

This is already included in #8380

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good PR This PR looks good to go, it needs comfy's final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

%date% formatting cannot be set for filenames via "String"
3 participants