4

By default, org-attach.el names project folders, using a UUID scheme, which is paired with headlines in org-mode, via the :PROPERTIES: drawer.

I would love to find a way to make this directory structure human readable, so that it can be accessed outside of org-mode (e.g., folder names are matched to headline names). So this outline structure:

* This headline
  ** This sub-headline 1
  ** This sub-headline 2
* This second headline

matches to the directory structure:

- This headline
  - This sub-headline 1
  - This sub-headline 2
- This second headline

Obviously, this presents an issue, should either of these get renamed. But maybe there is another way to get this done with UUIDs? Some possibilities:

  1. Match a UUID in the :PROPERTIES: drawer to a UUID in the folder's metadata (Spotlight comments on the Mac come to mind)

  2. Create a second folder structure via sim-links, that updates when org-attach-sync is called.

Any thoughts, ideas?

Thanks!

  • I just posted the question on the org-mailing list as well - let's hope for an answer. – Rainer Oct 13 '16 at 13:30
  • 1
    org-attach wiil respect each entry's ATTACH_DIR property. Of course you'd have to add that property yourself. – rpluim Jul 30 '18 at 14:50
2
+25

Define ATTACH_DIR Property Under Each Heading to Set an Human Readable Directory Path for Attachments

  1. Place cursor, a.k.a point, on heading.

    For this example, choose This headline

    * This headline
    ** This sub-headline 1
    ** This sub-headline 2
    * This second headline
    
  2. Press key chord C-c C-a s This headline Enter

    Note: You will need to remove the default full path to make directory relative to org file.

    The example should look similar to the following:

    * This headline
      :PROPERTIES:
      :ATTACH_DIR: This headline
      :END:
    ** This sub-headline 1
    ** This sub-headline 2
    * This second headline
    
  3. Attach files by pressing key chord C-c C-a a.

    For example, I attached file named junk001.org under This headline

    * This headline :ATTACH:
    :PROPERTIES:
    :ATTACH_DIR: This headline
    :Attachments: junk001.org
    :END:
    ** This sub-headline 1
    ** This sub-headline 2
    * This second headline
    

    Which created the file structure below:

    .
    ├── example1.org
    └── This headline
        └── junk001.org
    
    1 directory, 2 files
    
  4. Repeat steps 1-3 for other headings and files.

    If the directory paths change in future it should fairly straightforward to maintain paths by updating ATTACH_DIR values and renaming existing directories to match. It should be possible to automate updating directories to match heading and migrate files.

    * This headline :ATTACH:
    :PROPERTIES:
    :ATTACH_DIR: This headline
    :Attachments: junk001.org
    :END:
    ** This sub-headline 1 :ATTACH:
    :PROPERTIES:
    :ATTACH_DIR: This headline/This sub-headline 1
    :Attachments: junk002.org
    :END:
    ** This sub-headline 2
    * This second headline
    

    Which matches the directory tree below:

    .
    ├── example1.org
    └── This headline
        ├── junk001.org
        └── This sub-headline 1
            └── junk002.org
    
    
    2 directories, 3 files
    

Hope that helped!


Note: This answer was validated using the following software:
emacs version: GNU Emacs 25.2.1 (x86_64-unknown-cygwin, GTK+ Version 3.22.10)
org mode version: 9.1.2

0

Sometimes it is helpful to just say- I don't think that org attach has this capacity. Meaning, I have synced directories, but it does not recursively define a subtree based on the structure of the attached file.

I was trying to do this for some of my source... If someone wants to prove me wrong then go for it. But when I attach and sync the root directory and have the inherit flag set, all of the sub-directories do not get recursively generated in my org file as nodes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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