Fixing Markdown links post import

So, in my current Zettelkasten, I use wikilinks with just the UID – but often prepend with the note title outside of the link, like this:

# Related notes
[[UID]] This is the link title of link 1
[[UID]] This is the link title of link 2

Since Obsidian doesn’t support these links, I have to use the Markdown importer to convert this. But with either option the result will include redundancy:

# Related notes
[[UID This is the link title of link 1]] This is the link title of link 1
[[UID This is the link title of link 2]] This is the link title of link 2

or

# Related notes
[[UID This is the link title of link 1 | This is the link title of link 1]] This is the link title of link 1
[[UID This is the link title of link 2 | This is the link title of link 2]] This is the link title of link 2

How could I easily clean the important files to fix this? I would like either of these two possibilities:

# Related notes
[[UID This is the link title of link 1 | UID]] This is the link title of link 1
[[UID This is the link title of link 2 | UID]] This is the link title of link 2

# Related notes
[[UID This is the link title of link 1 | This is the link title of link 1]]
[[UID This is the link title of link 2 | This is the link title of link 2]]

I guess this is easy for someone a little more fluent in regex than I am – and using a search-and-replace in project in Atom, Sublime Text or similar?

[ is a special character for RegEx so you will have to \ it.
Furthermore when you want to re-use certain parts of your search for the replace you have to group them
Sublime will do the job with search in files
Activate the RegEx search by pressing the .* - button
In the search I would go for
(\[\[)(.{14})(.*)(.|.)(.*)(\]\])
14 supposed UID is YYYYMMDDHHMMSS
Now you have everything in groups which are number 1 for the [[2 for the UID…
In the replace you now use
/1/2/3/4/1/6 /5

Hope this is a little bit clear

1 Like