Hi, Daniel,

tocoda <[email protected]> writes:
>> Hello!
>>
>> I am using org-mode a lot for my notes in combination with
>> screenshots and other attachments. At some point I'd like to refile
>> these entries to some other file or change the outline structure by
>> introducing new headings with the previous attachments.
>>
>> For both cases I don't find any helper function for managing the
>> attachment files, i.e. moving the complete attachment folder to the
>> new location or moving some files from the previous entry to the new
>> attachment directory of the newly introduced entry.
>>
>> Is this a missing feature?

Org provides a function to move attachments to a different directory
(see point 1, below) and a feature to optionally delete attachments when
an entry is archived. But it does not, to my knowledge, support for
automatically moving attachments when refiling an entry. This would be
nice to have, but it sounds like a fairly complex task given the variety
of options.

A footnote in the Org manual provides the following tip: "If you move
entries or Org files from one directory to another, you may want to
configure org-attach-id-dir to contain an absolute path."

Obviously, this tip is more helpful before one starts capturing
attachments than after. :-/

> Maybe I am on the wrong page or missing something completely.
> Therefore I'd like to rephrase my previous question below:
>
> What is your workflow regarding attachments, when you refile an
> org-mode entry (with it's subtree) to a different file at some other
> location in the filetree?
>
> How do move attachments, when changing the outline structure?

It depends on how exactly you have attachments set up, and how complex
refiling you want to do.

If, for example, you have ID-based attachment directories and a lot of
entries to refile from the same document to target files in the same
target directory, it should be feasible to write a function to map over
the entries, determine the attachment dirs from their ID properties, and
move the attachment dirs over to the 'data' directory in the target
directory.

Assuming that the task is manageable with a manual workflow, here are
some suggestions. Others may have better ideas.

1. Org does provide org-attach-set-directory (C-c C-a s). If you're OK
with moving from whatever your current setup is to a :DIR: property and
absolute paths:

- Make sure that org-attach-dir-relative is nil (the
  default).

- Navigate to the entry you want to refile.

- Use 'C-c C-a s' to set a new attachment directory. You will be asked
  for a directory (created if necessary), asked if you want to copy the
  attachments over, and asked if you want to delete them. It's fairly
  painless.

- Your entry now has a DIR property with the absolute path to its new
  attachment directory, so you can simply refile it wherever you want.


2. If you are using -- and want to keep -- a default setup based on ID
properties and attachment directories with names like
`data/90/cd70a2-8924-46c9-82ac-117db4812989', you can move the
directories manually:

- Navigate to the entry

- Open the directory in dired (C-c C-a F) or system file manager (C-c
  C-a f), move up to the containing 2-digit directory (in the above
  example: 'data/90'), and rename or cut-and-paste it to where you want
  it, i.e. the data directory of the containing directory of the refile
  target.

- Refile the entry.

Do let us know how any of this works for you, to help us document it.

Regards,
Christian

Reply via email to