Is there a way to create a new unique note in the current folder?

What I’m trying to do

I would love to have an option to create a new unique note in the folder I am in right now. I know that you can do that using a regular “New note” by changing the setting. But my problem is that the regular new note is named “Untitled,” while my unique note can have a date-time name automatically. So basically, I would like to be able to have an automatic name assignment as in unique notes + automatic folder placement as in regular notes. Haven’t found a way to achieve that, yet.

2 Likes

This can surely be accomplished with a simple Templater script. Below I attached some code that you can paste into a note that is within the directory you have your scripts stored for the Templater community plugin (set in the settings). Also within the Templater settings are settings to allow for the use of hotkeys to trigger specific scripts. Here you will want to point to whatever note you have pasted the code. Finally, you can go into the hotkey settings for Obsidian, and define a hotkey for the script (you can find the command by typing the name of the script note).

At this point, you are all set, and pressing the hotkey will create a new note using the current date and time. You can alter how it is formatted by altering the script. As it is now, a note created at this moment November 2 2023 at 1:43:22 is 2023-11-02_01-43-22. I have tested it and it works, but I am not sure how to stop it from selecting the note title upon creation. Once I figure it out I will return, but in the meantime you can just use tab to jump into the note. This script can also be easily modified to use a specified template. See the Templater documentation for the tp.file.create_new command. It is quite easy, but I can explain further if needed. Anyways here is the code:

<%*
const fileName = tp.date.now()+moment().format('_HH-mm-ss');
tp.file.create_new("",fileName,true);
%>

But, considering you may not just want this new unique note to be empty or use a single defined template, you might be interested in this cool script from @AlanG at:

https://share.note.sx/2rskmna5

With this script, after choosing from a list of Templates that control what goes into the new note, you have the option to name the note in a dialog. If you don’t add a name, it automatically generates a name based on date and time, which can be configured as you like. It is all very well documented on the website.

Good luck!

3 Likes

Thanks a ton, this is exactly what I wanted! You just doubled my productivity) I knew about the Templater plugin, but did not want to mess with it. Learning Dataview was already a bit of a chore. But I see the power now.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.