Zettelkasten Forum


[REQUEST] Convert The Archive's copied links from [[YYMMDDHHMM Title]] to [[YYMMDDHHMM]] Title

edited April 2 in The Archive

I want to use "[[YYMMDDHHMM]] Title" when linking between notes, since this makes it possible to edit titles in the future, without breaking any existing links.

When using Cmd-C to copy a note title – or when right clicking to copy a note link – the result is YYMMDDHHMM Title or [[YYMMDDHHMM Title]]. Could Textexpander och Keyboard Maestro be used to convert what's in the clipboard to my desired format? Or is this a feature that are on the roadmap for The Archive?

Comments

  • Yes! Keyboard Maestro to the rescue. Not exactly what you asked for but it might work.

    Thanks to @kaidoh for the inspiration and Chris Stone who helped with the regex and @sfast for pointing out that the IDs should be separate from the zettel titles.

    This will convert "201811281633 - Book - The Physics of Life" to "Book -The Physics of Life [[201811281633]]" inserting it into a note, making the ID a link. Not sure why notes are not created like this in the first place. But I'm going with it for now.

    Setup In Keboard Mastro

    Macro in action - Choosing a Link

    The Results

    Here is the macro file
    The Keyboard Maestro macro file.

    Will Simpson
    kestrelcreek.com

  • Will - I've notice several of your Macros run the shell script "cd /Users/will/Dropbox/zettelkasten/
    ls | sed -E -e 's/.[^.]*$//' -e 's!^([0-9]+)[[:space:]-]+(.+)![[\1]] \2!'" or something similar.

    What exactly are you pointing to so I can figure out what the script should look like on my computer?

  • Will - I figured it out and what my problem was. Thank you for these resources!

  • edited September 21

    Hey @Will, can I ask a favor? I would like a macro that does exactly this but only outputs the ID in brackets, without the title at all. I'm trying to make sense of your sed statement and it's baffling me. Could you tell me what that would look like?

    Thanks!

    Edit: I found elsewhere the "inline note link" macro, which does what I need so I suppose this request is redundant. But I wouldn't mind seeing how you would do it in sed as well if you happen to have the time.

  • @mediapathic, try this:

    ls | sed -E -e 's/.[^.]*$//' -e 's!^([0-9]+)[[:space:]-]+(.+)![[\1]]!'
    

    i.e., just leave out the \2 at the end (which inserts the matched title).

  • @mediapathic -
    @msteffens is correct. Just leave off the \2. In the sed statement. There are 2 'Groups' here defined by the ( ). Group 1 is ([0-9]+) the note id number and Group 2 is (.+) the note title.

    At the end is the replacement part of the sed statement. This is where the Groups are manipulated. This sed statement says output [[ then Group 1 then ]] using the switch \1 which calls Group 1. You could just as easily output just the note name by replacing Group 2 with Group 1.

    The sed statement in the "inline note link" macro outputs the same result as the "insert note link" but KM only outputs the first 16 characters of the captured variable which happens to be the "[[201906131630]]" portion of the whole variable. Sloopy, but that was my state of knowledge at the time.

    This is not meant to be a sed tutorial. I am not a sed expert although I sometimes pretend to be one on the forum.

    Will Simpson
    kestrelcreek.com

Sign In or Register to comment.