You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<%*// rename file in the format "2024-01-13 00-46 - JOURNAL - - - - - -" if called Untitledif(tp.file.title.indexOf("ntitled")!=-1){letfileNameShouldBe=tp.date.now("YYYY-MM-DD HH-mm")+" - journal"for(vari=0;i<10;i++){letfileNameShouldBeFull=tp.file.folder(true)+"/"+fileNameShouldBe+".md"if(awaittp.file.exists(fileNameShouldBeFull)){fileNameShouldBe+=" -"continue;}awaittp.file.rename(fileNameShouldBe);break;}}else{// remove its contents otherwisevarfile=app.workspace.getActiveFile()setTimeout(function(){app.vault.modify(file,"")},500)}%><%*lettextToday=tp.date.now("YYYY-MM-DD")tR+=`[[${textToday}]]`%><%tp.date.now("HH:mm")%>
Much appreciated!
The text was updated successfully, but these errors were encountered:
Have you tried using the tp.hooks.on_all_templates_executed hook? Also I would consider a different way of getting the current file. Would look something like this.
tp.hooks.on_all_templates_executed(async()=>{varfile=tp.file.find_tfile(tp.file.path(true));// var file = app.workspace.getActiveFile();awaitapp.vault.modify(file,"");});
What kind of hook would you be looking for? I'm not sure what this template is trying to accomplish.
I have a shortcut on my android that when I click it it opens Obsidian and creates a file called Untitled in a specific folder.
Templater adds a property and textToday to the file
Templater renames the file from Untitled to current date.
If Templater sees that the file with the current date exists (maybe there were two created in the same minute), then it adds a dash at the end. This is attempted 10 times.
Once that's complete, I can start writing in the file.
Sometimes I want to spin off different files from that one. For example I may write [[Koenar]], and press on it.
Templater does its usual activities of writing textToday.
However, it does not need to, and I also don't need to change the file name, it's already correct - Koenar.
From there I just move the file (I have a shortcut CTRL+M, or a button above the keyboard on Android).
Some callbacks for deciding what name the file should have, with conditions, would be nice.
Also some callback to decide if templater should run for the file, or it should just leave the file blank.
I will give that hook a try, I had some issues with it yesterday..
Sometimes if Obsidian is lagging, the previous file I was in gets obliterated (content becomes empty).
Can there be more hooks?
I've considered increasing the time from 500 to 1500. It is still not perfect.
I've posted the code I'm working with right now at the end.
Much appreciated!
The text was updated successfully, but these errors were encountered: