Last active
April 3, 2021 17:06
-
-
Save et2010/891f142045b607d264982c6beb38b46a to your computer and use it in GitHub Desktop.
Rename the file that org-link pointed to and update the link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun et/rename-org-link-file (path) | |
(interactive | |
(list | |
(let* ((link (org-element-context)) | |
(old-path (org-element-property :path link))) | |
(read-string "PATH: " old-path nil old-path)))) | |
(let ((old-path (org-element-property :path (org-element-context)))) | |
(mkdir (file-name-directory path) t) | |
(rename-file old-path path) | |
(save-excursion | |
(goto-char (point-min)) | |
(while (search-forward old-path nil t) | |
(replace-match path))) | |
(message (format "Rename %s to %s" old-path path))) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment