From mboxrd@z Thu Jan 1 00:00:00 1970 From: Florian Lindner Subject: Re: Moving and resetting attachments Date: Thu, 1 Jun 2017 13:20:17 +0200 Message-ID: References: <874lw05njr.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGO9X-0004qb-E9 for emacs-orgmode@gnu.org; Thu, 01 Jun 2017 07:20:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGO9T-00016R-Bb for emacs-orgmode@gnu.org; Thu, 01 Jun 2017 07:20:31 -0400 Received: from [195.159.176.226] (port=43381 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGO9T-00015k-4i for emacs-orgmode@gnu.org; Thu, 01 Jun 2017 07:20:27 -0400 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dGO9L-0001pZ-B5 for emacs-orgmode@gnu.org; Thu, 01 Jun 2017 13:20:19 +0200 In-Reply-To: <874lw05njr.fsf@ericabrahamsen.net> Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Am 01.06.2017 um 06:39 schrieb Eric Abrahamsen: > Florian Lindner writes: > >> Hello, >> >> two questions about moving attachments to org files: >> >> C-c C-a a attaches a file and stores it under ./data/ID/... >> >> Using C-c C-a s I can set another directory a attachment directory. >> Can I make org-mode move the content of the previous >> directory to the new directory? >> >> Can I "reset" the attachment directory, i.e. like C-c C-a s but >> :ATTACH_DIR: is deleted and the contents of the previous >> directory are moved to ./data/ID? >> >> Rationale: >> >> I use org mode as a document management system. Create an entry Papers -> Interpolation -> ECCOMAS. I know create an >> custom attachment directory ECCOMAS, next to the org file as long as I >> am working on that paper. When it's finished, I >> want to move the contents of the ECCOMAS attachment directory to ./data/ID/. > > It doesn't work this way now, but I think it makes sense, and I would > also find that helpful. `org-attach-set-directory' could be changed to > check for existing files, and offer to move them. There's no > `org-attach-unset-directory', but I suppose there could be. Hey, I hacked together some lines of lisp that should achieve that. It's my first non-trivial (from my point of trivialness) piece of code. I'm open for any suggestions: (defun flo/org-attach-move () (interactive) (when (org-attach-dir) (let ((target (read-string "Move attachments to: ")) ; read-directory-name here? (attach-dir (org-attach-dir))) (if (string= target "") (progn (org-entry-delete nil "ATTACH_DIR") (setq target (org-attach-dir t))) (progn (org-entry-put nil "ATTACH_DIR" target) (make-directory target t)) ) (unless (string= target attach-dir) (copy-directory attach-dir target t nil t) (message "Deleting %s" attach-dir) ;; (shell-command "rm -rf %s" attach-dir) ) ) ) ) Best, Florian