franciskafieh / obsidian-list-modified

🪨 The advanced and adaptive changelog for Obsidian. Links all modified files meeting certain criteria to a timed (daily, weekly, monthly) note.
MIT License
85 stars 7 forks source link

Feature Request: Created & Deleted Files? #18

Closed brimwats closed 1 year ago

brimwats commented 2 years ago

This may be totally out of scope, so feel free to delete, but I would love if I could also print just files that were created on a specific date into my daily notes (i.e. not modified ones.) I've been using this python script if if's of any use to you. @kometenstaub wrote it:

# License: MIT 
# github username: kometenstaub

# requires at least python 3.5 (perhaps even a higher version), I have tested it on 3.9.5

# put it into the vault root 
#
# for UNIX: use cron to run it on a timer
#
# for windows: task scheduler -> new task -> trigger (the time you want) 
# -> start a program (put in the full path to this script)
# for windows you need to figure out how to do it exactly yourself as I am on Linux

# try it out by hand for a couple of days to see if it runs bug-free
# and please have backups

# note: on windows this will append the note names you created today to the daily note
# on linux these will be the notes you modified today

import os
import time
import re

createdFiles : list = []

# the following three can be changed to your liking
timePattern : str = "%Y-%m-%d"
dailyNotesFolder : str = "C:/Users/br/syncthing/booxsidian/100 - Personal/Daily/"
pathForLogs : str = "C:/Users/bri/syncthing/booxsidian/000 - Inbox. KO. Meta/_Templates/creation_log.txt"

timeToday : str = time.strftime(timePattern)

for dirpath, dirnames, files in os.walk("C:/Users/bri/syncthing/booxsidian"):
    if ".obsidian" not in dirpath and ".git" not in dirpath:
        for file_name in files:
            if file_name.endswith(".md"):
                normalised_path = os.path.normpath(dirpath + "/" + file_name)
                fileCTime = time.localtime(os.path.getctime(normalised_path))
                localFileTime : str = time.strftime(timePattern, fileCTime)
                if timeToday == localFileTime:
                    createdFiles.append("- [[" + re.sub(r"\.md$", "", file_name) + "]]")

try:
    with open(f"{dailyNotesFolder}{timeToday}.md", "a", encoding="utf-8") as f:
        f.write("\n\nNotes created today:\n\n" + "\n".join(createdFiles))
        with open(pathForLogs, "a", encoding="utf-8") as l:
            l.write(f"Success: {timeToday}.md\n")
except OSError:
    with open(pathForLogs, "C:/Users/bri/syncthing/booxsidian", encoding="utf-8") as l:
        l.write(f"Error: {timeToday}.md\n")

and this bat file to go with it:

"C:\Python39\python.exe" "C:\Users\bri\syncthing\booxsidian\000 - Inbox. KO. Meta\_Templates\today.py"
franciskafieh commented 2 years ago

can't promise i will implement this, but if i do, it will be with #9 ....

there might be a way to check if the file was just created without using another event (currently using the cache change event, could maybe check if the previous cache doesn't exist)

brimwats commented 2 years ago

I don't know how this works technically, but maybe bc your plugin knows what time it currently is couldn't it just check to see if created time was ~24h? or if there is a DD match?

franciskafieh commented 2 years ago

I don't know how this works technically, but maybe bc your plugin knows what time it currently is couldn't it just check to see if created time was ~24h? or if there is a DD match?

that could work, but there are so many ways to do it... could also use the create event, for example. the problem is mostly in the specific heading to place the links. not sure how i'm going to implement it, and it will be pretty difficult to do.

for now, since i'm really busy, i'm just trying to get the core features working. when i have time, i will try to add QoL things

chrisgrieser commented 2 years ago

just in case this is implemented, logging files deleted on that day might also be useful

TinkerSquirrel commented 2 years ago

A 'created today' section would be lovely. I'm currently using a Dataview query to create that in my daily notes - it's more stable/accurate than the 'modified today' query I used to use, but by no means future-proof.

franciskafieh commented 2 years ago

This would be nice to implement. Would need to also implement #3 for this to work. This is not the easiest to do, but it seems like a lot of people want it, so maybe I'll get to it when i have time!

franciskafieh commented 1 year ago

This will be implemented soon :tm:.... already closed #3 which is the first step! working hard on 2.0 and I hope i can get it released today or tomorrow

franciskafieh commented 1 year ago

P.S. @brimwats @chrisgrieser @TinkerSquirrel, I'd love for you all to help me beta test @Triquetra release 2.0. It's currently a pre-release, meaning you'll have to download it from BRAT or otherwise manual. I'll keep you all posted on further updated to created files in specific.

franciskafieh commented 1 year ago

Going to work on getting this done for 2.0 release!! Just released a new version that does not yet incude this, but I will get it done for next release.

franciskafieh commented 1 year ago

This seems to be trickier than expected. There's no easy create event I could hook into, although delete seems easy enough... Going to see how I can get this working.

franciskafieh commented 1 year ago

this should be done in release 2.1, which will release very soon after a little bit of further testing and bug fixes! Thanks for the patience, everyone!