Skip to content

Commit

Permalink
allow current timestamp in save image prefix (#4030)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Sep 9, 2024
1 parent e3b0402 commit 619263d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion folder_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,17 @@ def map_filename(filename: str) -> tuple[int, str]:
def compute_vars(input: str, image_width: int, image_height: int) -> str:
input = input.replace("%width%", str(image_width))
input = input.replace("%height%", str(image_height))
now = time.localtime()
input = input.replace("%year%", str(now.tm_year))
input = input.replace("%month%", str(now.tm_mon).zfill(2))
input = input.replace("%day%", str(now.tm_mday).zfill(2))
input = input.replace("%hour%", str(now.tm_hour).zfill(2))
input = input.replace("%minute%", str(now.tm_min).zfill(2))
input = input.replace("%second%", str(now.tm_sec).zfill(2))
return input

filename_prefix = compute_vars(filename_prefix, image_width, image_height)
if "%" in filename_prefix:
filename_prefix = compute_vars(filename_prefix, image_width, image_height)

subfolder = os.path.dirname(os.path.normpath(filename_prefix))
filename = os.path.basename(os.path.normpath(filename_prefix))
Expand Down

0 comments on commit 619263d

Please sign in to comment.