Obsidian Plugins: Templater (Part 2 - File Module)
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.
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?
What arguments control `tp.file.create_new`, and how do they affect the new file?
How can templates format dates differently for creation vs last modified times?
What’s the difference between `tp.file.folder` and `tp.file.folder` with `true`?
How does `tp.file.include` enable reuse of content blocks across templates?
How do cursor functions support multi-step templates like trackers?
Review Questions
- 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?
- When would you choose `tp.file.path` with `true` versus without it, and what kind of output difference should you expect?
- 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
Use `tp.file.content` to inject the target note’s existing text into a template, enabling copy-forward workflows across multiple notes.
- 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
Retrieve and format timestamps with `tp.file.creation_date` and `tp.file.last_modified_date` by passing a custom format string in brackets.
- 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
Add vault logic with `tp.file.exists` to return `true`/`false` for a given filename, supporting conditional template behavior.
- 6
Reuse markdown content blocks across templates using `tp.file.include`, including the ability to target a specific heading like “footnotes.”
- 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.