Using the Templater plugin to automatically move files to the desired folder when creating files with double links
Preparation#
- [[Templater]] plugin
- Templater Plugin Documentation
Configuration Process#
Configure the [[Templater]] Plugin Template#
- Create a
Templatertemplate storage folder calledtemplates - Create a template file in the template folder, and name it as
Linkfor example
Configure the Link Template#
- Write the following content in the template
- The purpose of this template is that when I create a file with double links, if I add a
Wcharacter at the end of the file name, the file will be moved to/Work/{filename}, and it will automatically remove theWcharacter, so no need to worry. - If you want to have more control, I believe you can understand this simple control code and modify it automatically.
- Please make sure that you have created the corresponding folder before moving the file!
<%*
let name = tp.file.title
if (name.endsWith("W")) {
await tp.file.move("/Work/" + name.substring(0, name.length - 1));
} else if (name.endsWith("B")) {
await tp.file.move("/Blog/" + name.substring(0, name.length - 1));
} else {
}
%>
Configure the Plugin#
Please note my writing process. I use the current double-link diary flow to write.
- My folder organization structure is as follows
Journal-Default entry for diaries
Blog-Folder for sharing
Notes-Default folder for notes, **default folder for double-link creation**
Work-Work record folder
templates-Template folder
- Set the editor - Save the folder created with double links in
Notes
- Configure the Templater plugin - Folder Templates project
- Create a new project, automatically use the
Linktemplate when creating a document inNotes, configure as shown in the figure
- Create a new project, automatically use the
Enjoy#
Now you can move documents according to the rules when creating documents with double links anywhere.
For example, according to my rule:
When I create a Obsidian使用心得B with double links, this document will be moved to the Blog folder and named Obsidian使用心得, isn't it nice!