ivan-lednev / obsidian-task-archiver

Archive completed tasks in your Obsidian vault (plus other org-mode-like features)
MIT License
109 stars 12 forks source link

Archive to Separate File using part of {{date}} as filename #74

Open SteveDockar opened 9 months ago

SteveDockar commented 9 months ago

Can anyone help? I would like to archive to a separate file based on one of the date fields. I would like to include part of the date as the filename rather than just file path, but cannot figure out if this is possible. What I would like to end up with is a file named for the Month of the current {{date}} (or possibly {{obsidianTasksCompletedDate}} ) in a folder for the year.

So, in folder view I would see /Archives/Tasks/2023/December (.md) for all tasks archived in December, based on a configured Filename something like /Archive/Tasks/{{date}}(.md) where the date format is 'YYYY/MMMM'. Unfortunately, without something after the date variable this doesn't seem to work. Using 'YYYY/MMMM' seems to try to create a 'MMMM' folder. What I do have working is ../{{date}}/Tasks which gives me a note/file called Tasks(.md) in the folder ../2023/December/ but I would ideally like to have monthly files in the year folder instead of the extra layer of folders.

All that said, @ivan-lednev the plugin is brilliant, and just what I was looking for, thank you! 🙂

ivan-lednev commented 9 months ago

Hi, @SteveDockar,

not sure if that's what you meant, but here is the result: image and here is the config: image

ivan-lednev commented 9 months ago

Archiving to month file: image image

SteveDockar commented 9 months ago

Hi @ivan-lednev , the bottom one is just what I was looking for but I couldn't seem to get to work.

⏳ ... ah! - When I had the Filename ending"{{date}}/tasks" it worked fine and created the tasks.md file as expected (except wasn't what I actually wanted). However, just ending the Filename with /{{date}} did not.

Then I noticed that your example began with the name of your folder in the Vault's root, whereas I'd got a '/' at the beginning of mine. So /Archives/{{date}} did not work, but Archives/{{date}} did. I suspect if none of them had worked, I would have found my way to the cause, but because the }}/filename version did, I didn't see the leading slash as an issue.

Thank you very much for replying so quickly and pointing me in the right direction. Hopefully this thread will help anyone else who makes the same mistake I did. 🙂