Skip to content

Incremental session numbers #1177

Answered by Zachatoo
pirilampr asked this question in Help
Aug 29, 2023 · 1 comments · 3 replies
Discussion options

You must be logged in to vote

It will depend on your file structure, but assuming your file structure looks like this

/
├── Worlds/
│   ├── Cosmere/
│   │   └── Session 001.md
│   │   └── Session 002.md
│   ├── Earth/
│   │   └── Session 001.md

You can have a script like this to rename a file based on the world and which session number you're on.

<%*
const folder = tp.file.folder(true);
const world = folder.split("/")[1]; // This will be different depending on how many levels deep in your folder structure your world name is
const sessionNumber = `${app.vault.getAbstractFileByPath(folder).children.length}`.padStart(3, "0");
await tp.file.rename(`Session ${sessionNumber}`);
-%>

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@pirilampr
Comment options

@Zachatoo
Comment options

Zachatoo Sep 2, 2023
Collaborator

Answer selected by pirilampr
@pirilampr
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants