I’m creating my own Zettlekasten-style template (I realise there is a default plugin for this but I want a little more customisation of my templates) using the Templater community plugin.
On applying the template to a file I want to:
Automatically set the title to be that of the current timestamp
Move the file to a ‘Notes’ folder (with the new title)
What I’ve tried
I’ve tried using this in my templates but am currently receiving a “template parsing error”.
<%*
// Set the current timestamp as the filename
await tp.file.rename(tp.file.creation_date("YYYYMMDDHHmmss"));
await title = tp.file.title;
// Move to the Notes folder
tp.file.move("Notes/" + title)
%>
Can anyone help to suggest how I may fix the issue and achieve the above two steps?
Ah, the problem was actually to do with paths as I made a small typo. I can confirm that your suggestion works perfectly, and cuts out an extra rename operation.
Yes, you do want a “/” between your folder name and your file name. Were your rename and move lines working independently? (i.e. if you tried just one of them)
I’m a little surprised that setting a variable in the middle of your call to rename (now move) is working. Do you use mytitle elsewhere? If not, can you get rid of just mytitle = from the line I quoted? Does that change anything?
The above works. It prompts me to input the name of the file before creating and puts today’s date before it in the file name.
What i’m trying to achieve
I would like to combine both of these functions and have not been able to get it to work thus far (my lack of knowledge).
What I would like to achieve when creating a new file from my template is to;
Be prompted to rename the file when creating, and
Automatically put in todays date in the file name/title, and
It’s very strange, I tried it with mytitle (before you suggested) and it didn’t make a difference.
Good point with the versions;
My Obsidian is V0.14.15,
Installer V0.13.31 (when I check for updates it says underneath “your app is up-to-date”
My Templater is 1.12.0
Does your developer console have any more information about the error? e.g. when I typo’d a variable name and got that error pop up, the console said “<typo’d variable name> not found”. To access the console: Ctrl-Shift-i on Windows/Linux or Cmd-Opt-I on macOS, and then go to the “Console” tab.