To get the folder name I’m using this templater script:
function getThisProject(tp) {
const thisFolder = tp.file.folder(false)
if (thisFolder == "Name of folder") {
return "Name of Folder";
}
return thisFolder;
}
module.exports = getThisProject;
I am currently able to retrieve the folder’s name of my note only, but not from its parent.
Any advice on how I should proceed ? (I need to tell I’m not confortable with Java)
I just want to clarify why your slice approach didn’t work, you were almost there: -2, 1 are not valid values in slice(-2,1) - slice(n1, n2) takes a ‘slice’ from index n1 to n2 using negative values for counting from the end of the array. So you were right about using -2, however you should also use -1 as the second parameter, that would give you the element 2nd to last. But slice() always returns an array so you would have to extract the first element of that array, like so: slice(-2, -1)[0] - or simply slice(-2)[0].
Same thing happened to me.
Had to remove a js file from the folder common with templater js files and then my default template worked…
Saved me some time here buddy.