0

I have an org file that has content like below:

:PROPERTIES:
:ID:       6dc9fdfe-d24a-4eaf-8152-1f663ba70a2e
:END:
#+title: example
* Header
[[attachment:filename]]

Here the file filename is in the folder that is named based on the ID value: .attach/6d/c9fdfe-d24a-4eaf-8152-1f663ba70a2e, and I can link to the file without any issue.

After I run org-id-get-create for * Header, I had a new ID added for the header, and it becomes something like below

* Header
:PROPERTIES:
:ID:       cd858afc-45ca-4f3d-bde8-a6f68c8acad0
:END:
[[attachment:filename]]

Now the attachment link to the file filename does not work any more, I have to move the file to a new folder for the new ID created, i.e., .attach/cd/858afc-45ca-4f3d-bde8-a6f68c8acad0.

This is annoying and I just wonder if there is a way to let the header * Header to search attachment in its parent's attachment folder as well? I tried to set org-attach-use-inheritance or set org-use-property-inheritance to t, but neither works.

1 Answer 1

0

The documentation (C-h i g(org)attachment options) says:

Inheritance works the same way for both ‘ID’ and ‘DIR’ property. If both properties are defined on the same headline then ‘DIR’ takes precedence. This is also true if inheritance is enabled. If ‘DIR’ is inherited from a parent node in the outline, that property still takes precedence over an ‘ID’ property defined on the node itself.

So in addition to the ID, try adding a DIR property with the parent's ID as value. Perhaps better, try making the parent's ID property a DIR property instead. If I read the doc right, that should allow you to add an ID property to the child and still have the attachment link work.

Untested.

2
  • The issue i have is that i am using org-roam, for which i always use org-id-get-create to make a header a roam node. Using :DIR: would work, but i have to manually add that to PROPERTY everytime i run org-id-get-create, in order to make sure any subheader will work by inheriting the folder from its parent...
    – shelper
    Commented Dec 23, 2021 at 19:04
  • IIUC, you only have to do that once per file: create it as a file property: #+PROPERTY: DIR foo.
    – NickD
    Commented Dec 23, 2021 at 19:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.