• Link to Youtube
  • Link to Reddit
  • Link to Soundcloud
  • Link to X
  • Link to Mail
  • Link to Discord
  • Link to Twitch
N.E.M. Productions
  • Home
  • Blog
  • Adam
  • Donation
  • Menu Menu
All The Things, Projects

Automating Obsidian

Obsidian is a great tool, and I’ve only just begun to understand it’s many uses. On the surface it’s simply a program to help with note taking. With plugins, some custom scripting, and a little bit of time however it seems it can do just about everything. For instance, you can link one note to another with the proper markdown tools. That alone makes organizing things as easy as linking a descriptor page for a topic in where it gets mentioned in the current form. When you need to view the descriptor, there you have it! I’m only a beginner in terms of my user-status however, so I really just know there are plugins and loads of things to try.

Like…. maybe… finding out you can run shell commands from a hotkey-press in Obsidian. So if I WANTED to I could randomly launch a word processor other than this one from pressing whatever I want. I also found out that you can publish to a WordPress website by clicking a button as well! So if I type something up here, all I have to do is add photos and click publish when the time is right!

Now on to the task at hand: Automation of Obsidian. Like I mentioned, it is an incredible tool if it’s used right. Using it right, however, means taking time to build the framework for what work flow is best for you. Personally I’m figuring it out as I go, and hoping that if I find a hiccup or find myself lacking in the ease of use I can fix it with some programming- which is exactly what I’ve done.

I’ve started to use this program for, among other things, keeping a loose journal on my life. Not really a day-to-day, but fairly often. One thing I want to do is at the top of each page have a link to the previous note, and the next one. Ideally, using it would be as simple as pressing a hotkey, and then a new note appears with today’s date as the title, the first line being a link to the last entry, and the next line being the entry I have yet to make. To make it seamless it will also have to edit the previous entry to have the correct link for the next note, and in the future if I find out I want some specific formatting, I’ll be able to add to it no problem!

This is pretty much all I know how to do for a project write up like this. I could go into what I had to do to code it but that’s just keyboard mashing and googling things.

On to the code I perhaps. It’s not the prettiest, but it works!


import glob
import os.path
import os
from datetime import datetime

now = datetime.today().strftime('%Y-%m-%d')
check_name = now + ".md"
path = r"F:\Documents\Mind Palace\Personal\Journal"
check = path + "\\" + check_name
check_file = os.path.exists(check)
stuff = []
uri = "obsidian://open?path=F%3A%5CDocuments%5CMind%20Palace%5CPersonal%5CJournal%5C"
URI = uri + check_name
 
linking = glob.glob(path + "\\*.md")
for i in linking:
    stuff.append(os.path.basename(i))

last_note = stuff[-1]
    
if check_file == False:
    it = open(check, "a")
    it.write("<<[[" + last_note[:-3] + "]]|| \n ||{{PLACEHOLDER}}>> \n")
    it.close

    print(path + last_note)

    with open(path + "\\" + last_note) as f:
        lines = f.readlines()
    lines[1] = "||[[" + now + "]]>>\n"
    b_file = open(path + "\\" + last_note, "w")
    print(lines)
    b_file.writelines(lines)
    f.close()
    
    os.system('start %s' % URI)
    
elif check_file == True:
    print("The file already exists.")
    os.system('start %s' % URI)


February 21, 2022/by Adam Maddox
Share this entry
  • Share on Facebook
  • Share on X
  • Share on WhatsApp
  • Share on Pinterest
  • Share on LinkedIn
  • Share on Tumblr
  • Share on Vk
  • Share on Reddit
  • Share by Mail
https://thisisnem.com/wp-content/uploads/2019/11/2019-10-24-10-00-53_front-300x200.png 0 0 Adam Maddox https://thisisnem.com/wp-content/uploads/2019/11/2019-10-24-10-00-53_front-300x200.png Adam Maddox2022-02-21 15:45:402022-02-21 15:45:40Automating Obsidian

Pages

  • About Adam Maddox
  • Blog
  • Donate
  • Homepage
  • My events!

Categories

  • All The Things
  • Blog
  • Personal Work
  • Projects
  • Published Articles
  • Uncategorized

Archive

  • February 2022
  • September 2021
  • December 2020
  • November 2020
  • August 2020
  • July 2020
  • May 2020
  • April 2020
  • March 2020
  • April 2017

NEM started a little while ago when I got bored and thought I needed something to do. Thank you for checking out my shenanigans.

Important Links

  • Blog
  • Adam
  • Donate

Recent Posts

  • Automating ObsidianFebruary 21, 2022 - 3:45 pm
  • A New Coding AdventureSeptember 14, 2021 - 2:00 pm
  • Wanna Play a Random Movie? No Problem!September 10, 2021 - 4:53 pm
© Copyright - N.E.M. Productions | Hosted by JNL Hosting
  • Link to Youtube
  • Link to Reddit
  • Link to Soundcloud
  • Link to X
  • Link to Mail
  • Link to Discord
  • Link to Twitch
Link to: A New Coding Adventure Link to: A New Coding Adventure A New Coding Adventure
Scroll to top Scroll to top Scroll to top