Skip to content

Instantly share code, notes, and snippets.

@et2010
Last active April 3, 2021 17:06

Revisions

  1. et2010 revised this gist Apr 3, 2021. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions rename-org-link-file.el
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@
    (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))
  2. et2010 created this gist Apr 3, 2021.
    14 changes: 14 additions & 0 deletions rename-org-link-file.el
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    (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))))
    (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)))
    )