This command could do what you want:
find -E data -type f -iregex ".*($(cat file-1.org | grep -i ':id:' | perl -pe 's/^\s*:id:\s*(\w{2})([\w-]+)$/$1\\\/$2/i' | paste -s -d'|' -)).*" -exec rsync -R '{}' ~/temp/my-new-directory \;
Replace file-1.org
with the org file whose attachments you want to move, and ~/temp/my-new-directory
with the location of your new directory. A data
directory will be created with the attachment files in them (if you want to move instead of copy, pass --remove-source-files
to the rsync
command).
This was tested on macOS. You might have to omit the -E
flag on other platforms.
NOTE: Please do this on a copy of your files. I'm not an expert in emacs, have never used org-mode attachments and I'm not experienced with using this kind of hacky file manipulation. This could blow your org-mode folder into oblivion so back it up first.
org-attach-sync
to sync them with the new item.