What I’m trying to do
I’m trying to write some Templater code to automatically rename chapters to order them properly.
My current code is as follows:
<%
let chapter = 1;
while (true) {
if (tp.file.exists("Chapter " + chapter)) {
chapter++;
} else {
await tp.file.rename("Chapter " + chapter);
break;
}
}
%>
If anyone can help further
I’d also like to be able to add a title to the file name. Something like “Chapter 1 - Prologue” and any new files created from this template ignore anything after the number when trying to determine the chapter count.