SilentVoid13/Templater

Using tp.file.rename doesn't rename current note but creates a new note instead

erldipin opened this issue · 2 comments

Plugin information (please complete the following information):

  • OS: Windows 10
  • Templater version: 2.4.2
  • Obsidian version: 1.4.7
  • Templater settings: [e.g. Template folder location: "Templates/", Timeout: "5" (add the templates not working with their associated command)]

My old template that used to work, appending a property called "Name" to the end of the current note:
let fileName = (app.workspace.getActiveFile()).basename; const fileNameTitle = DataviewAPI.page(tp.file.find_tfile(fileName).path) await tp.file.rename(tp.file.title + " - " + fileNameTitle.Name)

And the simplified test template:
await tp.file.rename(tp.file.title + " - " + tp.file.title)

Describe the bug
I run a template with tp.file.rename in an open note titled with the time and date, and it creates a new Untitled note called "Untitled - Name", using the Name property from the original note that I ran the template in. I simplified the code just to check if something got updated and the original code was broken, and I get a new note called "Untitled - Untitled" now.

Expected behavior
When I run a template using tp.file.rename, the filename of the currently open, active note should be changed, with the Name property appended to the end of the current title.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
I'm not very knowledgeable about coding so please let me know if the code isn't written correctly and it was a fluke that it worked in the first place. I cobbled together the original template together from various posts on the Obsidian forum.

I can't reproduce on the latest versions of Templater and Obsidian, am I doing anything differently? I've attached a video of using your simplified test template and it appears to be working fine.

2024-09-02_13-50-09.mp4

Obsidian version: v1.7.0
Installer version: v1.4.13
Templater version: v2.4.2

Closing due to no response.