Index: <% tp.file.folder() %>
Section titled “Index: <% tp.file.folder() %>”[!abstract] Purpose
🌟 Key Notes & Concepts
Section titled “🌟 Key Notes & Concepts”🔗 Related Areas
Section titled “🔗 Related Areas”🗂️ Full Contents
Section titled “🗂️ Full Contents”LISTWHERE file.folder = this.file.folder AND file.name != this.file.nameSORT file.name ASC<%*
// --- AUTO-RENAME SCRIPT v2 ---
// This version is more robust and will not fail on folders without underscores.
const folderName = tp.file.folder();
let baseName = folderName; // Default to the full folder name.
// Only try to split the name if an underscore exists.
if (folderName.includes(’_’)) {
// This part is the same as before, but now it’s safely inside an ‘if’ block.
const parts = folderName.split(”);
if (parts.length > 1) {
baseName = parts[1].trim().split(’ ’)[0];
}
}
// Construct the new filename using simple, safe string addition.
const newFileName = ‘_index-’ + baseName;
// Rename the current file.
await tp.file.rename(newFileName);
%>