I have a path like ‘~/org/3b/2d693a-83d9-40cc-a00f-71c227c5d7f5/’. I want extract ‘3b/2x693a-83d9-40ff-a00f-75d227c5d7f5’ using elisp. After extraction, I want convert ‘3b/2x693a-83d9-40ff-a00f-75d227c5d7f5’ into ‘3b2x693a-83d9-40ff-a00f-75d227c5d7f5’, then use ‘org-id-open’ to open it.

`M-x wr/go-back-to-node`, you can go back to the headline.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
(defun wr/second-last-element (list)
  (nth (- (length list) 2) list))

(defun wr/third-last-element (list)
  (nth (- (length list) 3) list))

(defun wr/go-back-to-node ()
  ""
  (interactive)
  (let ((file (if (equal major-mode 'dired-mode)
                      default-directory
                    (buffer-file-name))))
    (if file
        (let ((extracted-string-2nd (wr/second-last-element (split-string file "/")))
              (extracted-string-3rd (wr/third-last-element (split-string file "/"))))
          (setq converted-string
                (concat
                 (replace-regexp-in-string "/" "" extracted-string-3rd)
                 (replace-regexp-in-string "/" "" extracted-string-2nd)))
                (org-id-open converted-string t))
      (message "The node has not been added to Emacs yet."))))

Happy reverse to headline!