-
-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
allow folder templates to match on file name #471
Comments
Your folder template could match on filename and then use |
I ran into this same issue today, so decided to try if using regexes on file paths was feasible. It was. This works: (master...harmtemolder:obsidian-templater:master) This is nowhere near ready for a pull request, but I will work towards one. |
I'm thinking about a toggle to switch between the current folder templates and these file regexes, because I understand that regexes are not for everyone |
Has there been any movement on this? It's been over a year |
Any updates on this? |
This has been added in 2.7.3, thanks to @harmtemolder ! |
Problem
It's possible to apply per-folder templates, but there are often different styles of files combined in a folder that differ by file name pattern. Some examples:
logs / journals can have monthly, weekly, and daily notes, so the patterns might be e.g.
YYYY
/YYYY
-MM
YYYY
/YYYY
-WWW
YYYY
/MM
/YYYY
-MM
-DD
The current capabilities would only allow a folder template for
Log
, which clearly isn't specific enough. Even folder patterns as suggested in Support for wildcards when adding Folder Templates #418 would not solve this (since monthly and weekly notes are in the same directory), but being able to match the combination of folder and file pattern as e.g. folder/Log
and file pattern????-??
,????-W??
, or????-??-??
would fully identify the type (monthly / weekly / daily note.)In projects, data collections, etc., beside the actual data that should match the folder-specific template, there's often also metadata that should match global metadata templates.
README
files are probably the most common of those, I also have things likeINBOX
,TODO
,STATS
, ... Ideally, they they all have exactly the same structure, no matter where in the tree they are. So here the folder pattern would just be/
and the file patternsINBOX
/README
/ ..., i.e. no matter where in the tree, this template should be used for this particular file.Suggested solution
Extend the folder templates list from
(folder, template)
to(folder_pattern, file_pattern?, template)
(this would subsume #418).If present, a
file_pattern
match should be stronger than even a deepfolder_pattern
match, to allow global structure across all folders. (I think the end result is two layers: (1) both file + folder pattern match, pick the deepest of these. (2) no file pattern and only the folder pattern matches, pick the deepest as done currently.)Specific flavour of pattern doesn't matter. Glob-style would be nice (no need to escape
/
in paths), but plain regex works too. (Glob implementations exist - e.g. 'minimatch' - but I can't assess whether they're any good.)As a first step, even allowing only exact matches on file names (no patterns at all) would already solve many problems.
Alternatives?
Not aware of any, apart from manual workarounds.
Additional context
n/a
The text was updated successfully, but these errors were encountered: