I use the Tools > Item Links > Covert WikiLinks to Item Links script on Markdown files a lot, and it’s very useful.
Is there an equivalent script that could do the converse? I.e. take a Markdown Link with [Name of file](x-devonthink-item://<UUID>) and turn it into either a WikiLink [[Name of file]], or even a standard Markdown link [Name of file](path to file).
I can do the first (with some rough edges) using a series of regexes in say BBEdit or Vim, but that’s not really feasible over thousands of files, I think.
If there isn’t such a script, is the applescript for the Convert WikiLinks to Item Links available somewhere, so I could at least try to understand the concepts used (e.g. how to get at the list of links shown in the Inspector Panel)?
I know it’s a menu command! I wondered if it was also an AppleScript behind the scenes – one that had been written before and then incorporated into the main program, perhaps.
If not, have you come across such a script? I can’t find one using search.
Future proofing… If I have to move away from Apple, then how do I ensure that I do not lose the thousands of inter-document links I have, the majority of which are item links?
The only way I can see is to convert the links to WikiLinks or [Name](file path). If there’s a better way, then I’d be happy to explore it…
Using a document’s file path is not recommended as it’s not an absolutely static path. It’s also not recommended to link to a resource inside the database package as that’s no place for people to be rooting around.
There is no immediate solution to your inquiry… but… Are you just referring to Markdown documents and square bracket syntax?
I understand that I shouldn’t link to imported documents with a file path – I’ve never done that.
However, in the context of having to move to another OS, there is no DT database to worry about / grieve over: the files will all be exported to their own file system location mimicking the DT group structure. (And that location will be either Linux or FreeBSD, so there’s no Windows-Weirdness to mess around with the paths.).
In any case, this is no different to being able to link via file path to indexed files on a Mac, isn’t it? There’s more maintenance required with file-paths compared to x-DEVONthink-item links (or Hookmark links), but neither of those will be available on Linux / FreeBSD, unfortunately.
Of course, not every program supports WikiLinks anyway…
The vast majority of my notes are Markdown documents, so yes, that’s the main focus of my questions.
At the moment, I have a set of regexes that:
split the links out to their own lines
take the name of each link and surround it with double brackets
move the old x-DEVONthink-item links to the end of the file so that they’re not lost
This would be very tedious at scale! So I wondered if there was an AppleScript solution which made use of DT’s already collected knowledge of which links are in a document.
These absolute group links should work in DT as well as the original item links. But I have no idea if each and every MD processor in the wild will handle them as you intend with a DT database exported to the filesystem. Absolute “group paths” might not work as you wish, so some massaging might be needed after export.
Funny coincidence; Just yesterday I had the same thought and was looking for a way to do so. I am excitedly following this thread and hope @chrillek’s proposed script is working out for you