husjon / obsidian-file-cleaner-redux

A plugin for Obsidian to help clean up files in your vault
MIT License
29 stars 2 forks source link

Add configuration for what it means to be 'empty' #44

Open ee-usgs opened 7 months ago

ee-usgs commented 7 months ago

I have lots of effectively empty daily notes 'Daily notes' plugin. That plug allows a template to be used when it creates a new notes, so those files are not exactly empty - they have the contents of that template.

For Daily Notes from a template, it might be nice to have an option that says, 'If a file matches this template and has no other content, consider it empty'. More generally, perhaps the simplest/most flexible way to do that is to have a regex expression that, if it matches the entire contents of the file, causes the file to be considered empty.

husjon commented 7 months ago

I've been having a think about this issue for the last few days and I'm unfortunately not able to come up with a good solution.

Here are the problems I'm facing:

  1. The difference between the actual template and the pattern needed to match the file will be different, hence you need to maintain it twice (this also depends on if you're using the built-in template engine or for example the Templater plugin).
  2. Regular expressions are expensive operations, since we're talking about rather big patterns over quite a few files (as in the entire vault) this can result in really long run times.

I will leave the issue open in case I or someone else comes up with something, but I cannot guarantee a quick implementation.

What could help is if you could give an example of the template you use and just a dummy example of a filled out daily note (no personal details etc). This would at least give me something to look into and benchmark.

klemmster commented 5 months ago

I'm facing the same issue. This is my template right now:

# Plan
- [ ] 
# Notes

# Standup
- [ ] 
husjon commented 5 months ago

It is however important to realize that the user themselves will have to maintain their own regular expression patterns because of the vast amount of different templates out there.

As I am in the process of rewriting the plugin and will be adding support for finding attachments which are used in Admonition code blocks using regular expressions, this might make this feature possible as well.

For now I will not add the issue to the v1.0.0 milestone but I'll definitely keep it in mind.