Skip to content

Renaming attached images moves them to the wrong directory #209

@gsingh93

Description

@gsingh93

When org-download-method is set to attach, the download file is placed in a subdirectory of org-attach-id-dir, where the node ID is used as the subdirectory path. For example, create an empty org file, copy the following URL to your clipboard, and then run M-x org-download-yank: https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png

The buffer will now look like this (but with a different ID):

#+DOWNLOADED: https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png @ 2023-05-31 15:08:20
[[attachment:data/BD/A97238-B45D-4FA1-82EE-DC2523033886/2023-05-31_15-08-20_Example.png]]
:PROPERTIES:
:ID:       BDA97238-B45D-4FA1-82EE-DC2523033886
:END:

Now run M-x org-download-rename-last-file and replace the name with "foo" and hit enter. The buffer will now look like this:

#+DOWNLOADED: https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png @ 2023-05-31 15:08:20
[[attachment:data/BD/A97238-B45D-4FA1-82EE-DC2523033886/foo.png]]
:PROPERTIES:
:ID:       BDA97238-B45D-4FA1-82EE-DC2523033886
:END:

But this link is now broken, as the image no longer exists at that location. It's been moved relative to the org file itself. If you add a link like [[file:./foo.png]], that will point to the file.

I believe the intended behavior should be that only the filename should change, not the directory. In this example, "./foo.png" should not have been created, but "data/BD/A97238-B45D-4FA1-82EE-DC2523033886/foo.png" should have been created.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions