obsidian-folder-note-plugin icon indicating copy to clipboard operation
obsidian-folder-note-plugin copied to clipboard

After renaming the folder, backlinks to the folder note are not updated automatically

Open joellti opened this issue 3 years ago • 4 comments

Following is the initial setup.

.../some.md [[Note 1]]

Note 1/ Note 1.md

Then I change the folder from Note 1 to Note 2. As expected, Note 1.md is auto renamed to Note 2.md. But [[Note 1]] inside some.md stayed the same instead of being updated to [[Note 2]]. So we end up with an inconsistent situation.

joellti avatar Mar 01 '21 06:03 joellti

Thanks for the information. Yes, there are some renaming issues need to be addressed in the future. Do you use the outside folder note mode? If so, you can try to change the Note 1.md's title to Note 2, then, the folder name will be changed to be Note 2, and the link in some.md will be changed to [[Note 2]]

xpgo avatar Mar 08 '21 23:03 xpgo

My experience is very similar. I find the root cause, although I am not able to solve it now.

I use absolute link and "inside folder note mode". My setting is

.../some.md
[[Note 1/Note 1.md]]

Note 1/
Note 1.md

After renaming "Note 1" folder to "Note 2", the "Note 1.md" automatically rename to "Note 2.md", which is great. However, the link is [[Note 2/Note 1.md]].

I debug a little and find the reason is vault.rename doesn't trigger link update. I believe this is an Obsidian bug, I have reported it at Vault.rename(file, path) doesn’t trigger link update. Hope it get solved soon.

anselmwang avatar Feb 12 '22 06:02 anselmwang

@xpgo , I have found the solution to this problem. As pointed out in link Vault.rename(file, path) doesn't trigger link update - Developers & API - Obsidian Forum, API "renameFile" will rename and update links.

I have tried the API this.app.fileManager.renameFile(this.app.vault.getAbstractFileByPath("abc/abc.md"), "abc/abc2.md") and it works. I think using this API could fix this bug. May I know whether you prefer me to send a PR or you'd fix it by yourself?

anselmwang avatar Feb 17 '22 06:02 anselmwang

Just find alx-folder-note which is a fork and rewrite of folder-note. It solves the renaming problem.

anselmwang avatar Feb 20 '22 04:02 anselmwang