Error when applying templates to files with both Latin and Cyrillic characters in the filename
ruslanrmv opened this issue · 1 comments
Description:
I encountered an issue with the Templater plugin in Obsidian. The problem occurs when I try to apply a template to a file whose name contains both Latin and Cyrillic characters. The plugin throws an error indicating that certain characters (like \, /, :) are not allowed in the filename, even though these characters are not present in the actual filename.
Additionally, the file renaming function inside the template does not work when applied to these filenames. Specifically, I am using the following code in my template:
<% await tp.file.rename(tp.date.now("YYYYMMDDHHmm" + " – " + tp.file.title)) %>
When this code attempts to rename the file, the process fails and throws an error regarding invalid characters, even though no forbidden characters are used in the new filename.
This revised description now clearly states that the renaming function doesn’t work when applying templates to files with both Latin and Cyrillic characters.
Steps to Reproduce:
1. Create or open a note whose filename contains both Latin and Cyrillic characters (e.g., Note_Заметка.md).
2. Use a template that includes the code provided above to rename the file.
3. Observe the error message.
Expected Behavior:
The template should apply successfully to the note, renaming the file as expected, since the filename doesn’t contain any forbidden characters.
Actual Behavior:
An error is thrown, claiming that characters such as \, /, : are not allowed in the filename, even though none of these characters are present.
Possible Cause:
It seems that the plugin or the underlying file-handling mechanism in Obsidian does not correctly process filenames that combine both Latin and Cyrillic characters, especially when attempting to rename the file via the template. This could be related to character encoding or validation issues during the renaming process.
Environment:
• Obsidian Version: 1.6.7
• Templater Version: 2.8.0
• Operating System: MacOS 15.0.1
The issue is that you are including the note name in tp.date.now(...)
, so Templater is trying to convert the characters in the file name to a date, which is likely not what you want to do.
Try doing something like this instead. I moved the )
for tp.date.now
so that it only encompasses the date tokens, and not the file name.
<% await tp.file.rename(tp.date.now("YYYYMMDDHHmm") + " – " + tp.file.title) %>
Closing for now, if you're still having issues after this change we can reopen this and continue discussing!