What I’m trying to do
Hi, I’m trying to let templater increment the files name by 1 if it already exists in a folder. Usually i would just let this be done by Quickadd but it doesn’t work, because the new notes creation folder is not the same as its storing folder. (I do this so it can automatically link to the project this meeting is associated to.) Quicknote generates the files name before acutally creating the file, so it logically does not check the final folder for dublicates.
Things I have tried
I have looked online, but did not find any solution. I tried to make a script but that doesn’t seem to work.
<%*
const meetingsFolder = 'Meetings/';
const today = tp.file.date('YYYY-MM-DD');
let meetingNumber = 1;
let meetingName = `Meeting ${today} No. ${meetingNumber}`;
while (tp.file.exists(meetingsFolder + meetingName)) {
meetingNumber++;
meetingName = `Meeting ${today} No. ${meetingNumber}`;
}
tp.file.rename(meetingName)
%>
When trying to run this template Obsidian just freezes and I am forced to close the program.
What is my goal?
- Click a Button on the projects page
- Open a new note + automatic name added via quickadd (Meeting + date + No.1) (still in the project folder)
- execute the template commands
- check the “Meetings/” folder rename the note if the date and No. already exists by incrementing the No. by 1.
- move the newly renamed file to “Meetings/”