You can’t compare a date with a text string, so when you do the toFormat() on the first part, you need to match it with a text string, like using file.name or doing a similar formatting to make that date into a text string too.
Depending on which template engine you’re using (that is the core template or Templater plugin), you could have inserted either {{date:YYYY-MM-DD}} (I think… ) or <% tp.date.now() %> instead of today in your template.