# Templater: how to save a file created with templater to a dynamic folder?

**URL:** <https://forum.obsidian.md/t/templater-how-to-save-a-file-created-with-templater-to-a-dynamic-folder/115854>\
**Category:** Help\
**Tags:** templater\
**Created:** [July 4, 2026, 8:57am UTC](https://forum.obsidian.md/t/templater-how-to-save-a-file-created-with-templater-to-a-dynamic-folder/115854 "2026-07-04T08:57:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChuckZ](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/c/22d042/32.png) [@ChuckZ](https://forum.obsidian.md/u/ChuckZ)\
**Post date:** [July 4, 2026, 8:57am UTC](https://forum.obsidian.md/t/templater-how-to-save-a-file-created-with-templater-to-a-dynamic-folder/115854/1 "2026-07-04T08:57:40Z")

</div>

Hello fellow Obsidians,

I’ve recently started to go to the gym and wanted to journal my gym workouts.  
Also, I wanted to make a template for each variation of my workout, with checkboxes so that I can keep track while working out of what I’ve done and what’s left to do.

I’ve stumbled accross a blogpost with a solid base that I wanted to expand upon. Unfortunately I can’t include the link for reference, but you would find it with a quick research for:

> Workout Log in Obsidian I Josh

So, to make it simple, I have:

- three files, called J1\_Template, J2\_Template and J3\_Template.md, one for each of the weekly variations of my workout;
- a file with all my exercise informations (weights, reps, series, rests, etc.);
- a file called LaunchWorkout.md that has 3 buttons, one for each of the 3 variations of my workout.

When I click on one of these buttons, templater creates a new file based on that specific template and saves it in a custom folder where I have my jounaling stored. Here’s the J1 button code:

```auto
style: primary
label: J1
actions: 
- type: templaterCreateNote
  folderPath: "Journaling/Workout"
  templateFile: "Journaling/Templates/D1_Template.md"
  openNote: true

```

A prompt appears and suggests today’s date as a name, and then templater appends the variation selected to rename the file. Here’s the code for that:

```javascript
// Prompt the user for the date, defaulting to today
let date = await tp.system.prompt("Date?", tp.date.now("YYYY-MM-DD"));

// rename the file using today's date and the selected workout type
await tp.file.rename(date + " - D1 Workout");

```

### What I’m trying to do

So, what I would like to achieve, is that the files get stored using the date.

Let’s say that I created a file today, July the 4th. I would like that file to be saved like this:

```auto
Journaling/Workout/2026/07 - July/2026-07-04 - D1 Workout.md

```

### Things I have tried

So far, I tried using this as the default prompt:

```javascript
// Prompt the user for the date, defaulting to today
let date = await tp.system.prompt("Date?", tp.date.now("YYYY/MM - MMMM/YYYY-MM-DD"));

```

but templater returns an error: _filenames cannot contain slashes_.

That means I have to find a way to check that the year and month folder already exist, and then maybe MOVE the created file to the right folder. But I’m not sure how to do that. (I’m also pondering adding a button to my templates that stores the file conveniently, that I could press once the session is finished or the data is reviewed or whatever)

### Also, I have an unexpected behavior that I would like to address (this is very minor, but since I’m here)

In my template, I have this:

```auto
<%* for (const exerciseKey in exercises) { _%>
- <% exercises[exerciseKey] %> :
	<%* if (weight[exerciseKey] != "Bodyweight") { _%>
	- [] **Warmup :** <% reps[exerciseKey] %> reps with <% warmupWeight[exerciseKey] %>k
	<%* } _%>
	- [] **Workout :** <% series[exerciseKey] %> series of <% reps[exerciseKey] %> reps with <% weight[exerciseKey] %>k – rest: <% rests[exerciseKey] %>s
		<%* for (let i = 0;i < series[exerciseKey]; i++) { _%>
		- [] <% i+1 %>
		<%* } _%>

<%* } _%>

```

Gets me that result:

 ![image](https://forum.obsidian.md/uploads/default/original/3X/a/e/ae4fb0b26b024d703ab308109eb85525e398b60d.png)

As you can see, the next iteration of the first for loop is indented, and I don’t know how to put it back to the far left of the document, same as the previous exercise. Any ideas?

---

<div class="post-metadata">

**Author:** ![Zachatoo](https://forum.obsidian.md/user_avatar/forum.obsidian.md/zachatoo/32/24205_2.png) [@Zachatoo](https://forum.obsidian.md/u/Zachatoo)\
**Post date:** [July 20, 2026, 4:46am UTC](https://forum.obsidian.md/t/templater-how-to-save-a-file-created-with-templater-to-a-dynamic-folder/115854/2 "2026-07-20T04:46:28Z")

</div>

For the first issue, try using `tp.file.move` instead of `tp.file.rename`.

For the second issue, it’s an issue with your [whitespace control](https://silentvoid13.github.io/Templater/commands/whitespace-control.html). Try something like this instead. I swapped out `_%>` for `-%>` and removed indentation on the second to last closing brace.

```js
<%* for (const exerciseKey in exercises) { -%>
- <% exercises[exerciseKey] %> :
	<%* if (weight[exerciseKey] != "Bodyweight") { -%>
	- [] **Warmup :** <% reps[exerciseKey] %> reps with <% warmupWeight[exerciseKey] %>k
	<%* } -%>
	- [] **Workout :** <% series[exerciseKey] %> series of <% reps[exerciseKey] %> reps with <% weight[exerciseKey] %>k – rest: <% rests[exerciseKey] %>s
		<%* for (let i = 0;i < series[exerciseKey]; i++) { -%>
		- [] <% i+1 %>
<%* } -%>
<%* } -%>

```

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [October 18, 2026, 4:46am UTC](https://forum.obsidian.md/t/templater-how-to-save-a-file-created-with-templater-to-a-dynamic-folder/115854/3 "2026-10-18T04:46:36Z")

</div>

Closed on October 18, 2026, 4:46am UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
