obsidian-file-cleaner-redux icon indicating copy to clipboard operation
obsidian-file-cleaner-redux copied to clipboard

Feature Request: Option to include markdown files (with content) in cleanup

Open owbosh opened this issue 10 months ago • 5 comments
trafficstars

I understand this sounds strange and even dangerous. But sometimes markdown notes are not actual notes in the typical sense, the prime examples coming from the crop and annotate feature in Excalidraw (If you want an idea of it watch this: https://youtu.be/uHFd0XoHRxE).

Basically, Excalidraw is creating drawing notes that contain a single image plus some extra information such as the cropping data or annotations. These are considered to be attachments by me, not real notes. Therefore, I'd like them to be treated as attachment files (deleted if no markdown notes are linking to them).

Now I know including markdown files in the clean-up sounds dangerous (perhaps a red warning should be included in the setting or place it under the Danger zone?). But, if I limit the clean-up to only check my attachment folder (which are where these cropped/annotated files are created by default), then nothing should go wrong.

owbosh avatar Dec 29 '24 13:12 owbosh

If you want an idea of it watch this: https://youtu.be/uHFd0XoHRxE

This is a really neat feature.

I don't see it as a problem to tag certain markdown files to be cleaned up even if it has content. It would be up to the user to enable it and narrow down what is deemed cleanable. It is partially supported with frontmatter exclusion although only if content is empty, however note content is a bit harder since it's not really structured (compared to yaml in frontmatter).

This issue is somewhat related to #44 which has been here since March, I am still not really sure how to implement it yet though. The problem with this would be that the user has to maintain a regular expression to figure out if the file in question matches the content that should be included in the cleanup. Also, the more patterns the longer it takes to search each file + the size of the pattern increases time too.

I think it would be cool to try to implement and I am willing to hear how it would perform, but I am hesitant due to the time aspect.

husjon avatar Dec 29 '24 23:12 husjon

My idea is the simple approach: there would be a toggle (probably under the 'Danger zone' in settings) to simply treat ALL markdown files as attachments. If a markdown file is not being linked to by another markdown note, it is cleaned up. Obviously this would need to be combined with folder limiting or ignored frontmatter so it doesn't destroy your actual notes.

ghost avatar Dec 30 '24 03:12 ghost

Yeah, having it under Danger Zone might be the right place to put since it can be very destructive. I need to have a think about how to implement this while also not affecting the rest of the cleanup.

Obviously this would need to be combined with folder limiting or ignored frontmatter so it doesn't destroy your actual notes.

Yeah, having a way to say only do this for the files in a specific folder would be essential. Alternatively or as an addition would be to add a frontmatter key that you could add to these notes, not sure of the name yet but something like file_cleaner_force: true and any file that has this tag no matter the location will be checked for this rule (as in if there are no links to it, then it will be removed)

husjon avatar Dec 30 '24 17:12 husjon

I am also looking for this feature due to unused daily notes which are associated with a template.

RunsOnRum avatar Mar 13 '25 00:03 RunsOnRum

@RunsOnRum regarding templates, your issue might be more related to #44, although this issues (#80) is also kind of related to it too. This issues (#80) in particular differs slightly by saying anything in a specific folder can and will be removed no questions asked, while #44 is trying to define emptiness with rules.

The issue with doing this for daily notes (and it's why I'm referring to #44), is because there needs to be a way to differentiate between a an "empty" (empty as in only template content is there) daily note and one that has been filled to some degree.

I currently do not have a good idea as to how to implement either of these issues and this is also why both have little activity in them but I do hope that I can come up with something relatively soon unless someone else wants to give it a shot :)

husjon avatar Mar 15 '25 22:03 husjon