Get AI summaries of any video or article — Sign up free
Obsidian Plugins: Templater (Part 2 - File Module) thumbnail

Obsidian Plugins: Templater (Part 2 - File Module)

Productivity Guru·
5 min read

Based on Productivity Guru's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Use `tp.file.content` to inject the target note’s existing text into a template, enabling copy-forward workflows across multiple notes.

Briefing

Templater’s File module turns Obsidian templates into file-aware automation: templates can read note content and metadata, create and move files, and even pull in sections from other markdown files—without manual copy/paste. Instead of treating templates as static text, the File module lets commands like `tp.file.content`, `tp.file.title`, and `tp.file.create_new` dynamically fill in values based on the target note or vault state, which is especially useful for repeatable workflows such as trackers, structured note creation, and consistent naming.

The module’s first capability is direct content access. `tp.file.content` inserts the current note’s full text into the template output, and the demo shows it copying the same content into different notes when the template is applied. From there, creation commands expand automation. `tp.file.create_new` creates a new file using either a specified template or literal content, with arguments for the new file’s name (defaulting to “untitled”), whether to open the new file in a new window (`open_new`), and which folder to place it in. A practical example uses a template named “demo” to generate a file named “test,” opening it immediately.

Date and cursor controls make templates feel interactive. `tp.file.creation_date` retrieves a note’s creation timestamp, and the output format can be customized inside brackets (e.g., specifying `yyyy` and time formatting). `tp.file.cursor` then places the cursor at a specific insertion point after the template loads, with multiple cursor positions supported (toggled via the user’s hotkey—Option+Tab on macOS in the example). For appending text at the active cursor, `tp.file.cursor_append` inserts additional content after the cursor location.

The module also supports vault logic and navigation. `tp.file.exists` checks whether a given file name exists and returns `true` or `false`, enabling conditional template behavior. `tp.file.folder` retrieves the folder name, and a `true` flag switches between relative and full vault path behavior. `tp.file.include` pulls content from another file—optionally targeting a specific markdown heading—so templates can reuse sections like a “footnotes” block.

For ongoing maintenance and organization, `tp.file.last_modified_date` fetches the last edit time with customizable formatting. `tp.file.title` extracts the current note’s title, which becomes a building block for renaming and moving. `tp.file.move` relocates a file to a specified folder, while `tp.file.path` returns absolute or vault-relative paths depending on a boolean flag. `tp.file.rename` changes the file name while keeping the extension intact.

Finally, the module supports context extraction and advanced composition. `tp.file.selection` grabs the active text selection, and `tp.file.tags` returns all tags found in the file (including duplicates). The transcript closes with combined examples that chain date functions from the earlier video (like `tp.day.now` and `tp.date.weekday`) with file metadata (title, selection, last modified date) to compute offsets such as “five days ahead,” “minus five days,” and “next Monday,” demonstrating how File module outputs can feed directly into date logic for consistent, automated scheduling.

Cornell Notes

Templater’s File module makes Obsidian templates dynamic by reading and manipulating notes. It can insert a note’s full text (`tp.file.content`), create new files (`tp.file.create_new`), and fetch metadata like creation date (`tp.file.creation_date`), last modified date (`tp.file.last_modified_date`), title (`tp.file.title`), tags (`tp.file.tags`), and paths (`tp.file.path`). It also supports vault operations such as checking existence (`tp.file.exists`), including sections from other files (`tp.file.include`), moving/renaming files (`tp.file.move`, `tp.file.rename`), and placing or appending at cursor positions (`tp.file.cursor`, `tp.file.cursor_append`). These capabilities matter because they enable repeatable workflows like trackers, structured note creation, and consistent naming without manual editing.

How does `tp.file.content` help when applying a template to different notes?

`tp.file.content` inserts the current note’s entire existing text into the template output. In the demo, a template containing `tp.file.content` was applied to multiple notes; each time, the inserted content matched whatever text already existed in that target note, effectively copying the note’s current body into the template result.

What arguments control `tp.file.create_new`, and how do they affect the new file?

`tp.file.create_new` takes bracketed arguments including: `template` (either a template name to use or literal content in quotes), `file_name` (defaults to “untitled”), `open_new` (whether to open the created file in a new window; the demo warns it executes on the new file rather than the previous one), and `folder` (defaults to Obsidian’s default location). The example created a file named “test” using content from a “demo” template and opened it in a new window.

How can templates format dates differently for creation vs last modified times?

Both `tp.file.creation_date` and `tp.file.last_modified_date` accept a formatting string inside brackets. The transcript shows customizing output beyond the default “year month date hours and minutes” style by adding a format like `mmm space, yyyy` (with the exact formatting tokens placed in quotes). Running the template then outputs the timestamp in the requested format.

What’s the difference between `tp.file.folder` and `tp.file.folder` with `true`?

`tp.file.folder` retrieves the folder name, while adding `true` switches to a relative-path style output. The demo highlights that when a note is in the root vault, folder-related outputs can be empty; when placed in nested folders (like “demo” and “demo 2”), the relative path reflects the folder hierarchy more clearly.

How does `tp.file.include` enable reuse of content blocks across templates?

`tp.file.include` pulls content from another file into the current template. It can include an entire markdown file or target a specific section by heading. The example used `markdown` as the file and `footnotes` as the heading, inserting only that “footnotes” block into the new template output.

How do cursor functions support multi-step templates like trackers?

`tp.file.cursor` moves the cursor to a specified insertion point after the template loads, and multiple cursor positions can be defined (e.g., cursor 1 through cursor 5). The demo used a sleep tracker workflow: cursor positions correspond to fields like sleep time, quality sleep, deep sleep, and wake time, navigated via the configured hotkey (Option+Tab on macOS). `tp.file.cursor_append` then inserts text after the active cursor location.

Review Questions

  1. If you want a template to insert only a specific section (not the whole file) from another note, which File module function and argument pattern should you use?
  2. When would you choose `tp.file.path` with `true` versus without it, and what kind of output difference should you expect?
  3. How can `tp.file.title` be used as an input to `tp.file.move` or `tp.file.rename` to automate naming and organization?

Key Points

  1. 1

    Use `tp.file.content` to inject the target note’s existing text into a template, enabling copy-forward workflows across multiple notes.

  2. 2

    Create new notes with `tp.file.create_new` by supplying a template/content source, a file name, an `open_new` behavior, and a destination folder.

  3. 3

    Retrieve and format timestamps with `tp.file.creation_date` and `tp.file.last_modified_date` by passing a custom format string in brackets.

  4. 4

    Control where the cursor lands after template expansion using `tp.file.cursor` (multiple positions supported) and add text at the active cursor with `tp.file.cursor_append`.

  5. 5

    Add vault logic with `tp.file.exists` to return `true`/`false` for a given filename, supporting conditional template behavior.

  6. 6

    Reuse markdown content blocks across templates using `tp.file.include`, including the ability to target a specific heading like “footnotes.”

  7. 7

    Automate organization by chaining `tp.file.title`, `tp.file.move`, `tp.file.rename`, and `tp.file.path` to compute destination names and locations from note metadata.

Highlights

`tp.file.content` makes templates note-aware by inserting whatever text already exists in the target note.
`tp.file.create_new` can generate a new file from either a template name or literal content, with control over opening behavior and destination folder.
`tp.file.include` can pull in a specific markdown heading block (e.g., “footnotes”) rather than copying an entire file.
Cursor placement (`tp.file.cursor`) supports multi-field templates, letting users fill structured trackers in a guided sequence.
Chaining file metadata (title/selection/dates) with date math enables computed schedules like “five days ahead” and “next Monday.”

Topics