# How to copy the org-protocol://roam-file... URL to any org-roam file?

**URL:** <https://org-roam.discourse.group/t/how-to-copy-the-org-protocol-roam-file-url-to-any-org-roam-file/1566>\
**Category:** How To\
**Created:** [May 9, 2021, 7:00pm UTC](https://org-roam.discourse.group/t/how-to-copy-the-org-protocol-roam-file-url-to-any-org-roam-file/1566 "2021-05-09T19:00:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![laotang](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@laotang](https://org-roam.discourse.group/u/laotang)\
**Post date:** [May 9, 2021, 7:00pm UTC](https://org-roam.discourse.group/t/how-to-copy-the-org-protocol-roam-file-url-to-any-org-roam-file/1566/1 "2021-05-09T19:00:46Z")

</div>

If I generate a graph with `org-roam-graph` it includes links back to my notes in Emacs / org-roam (of the type `org-protocol://roam-file?file=%2FUsers%2Forg%2F20200712212306-freedom.org`). I was wondering how to create these URLs when I am in Emacs, visiting an org-roam file. This probably is trivial but I have been unable to figure it out so far.

---

<div class="post-metadata">

**Author:** ![gcoladon](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/gcoladon/32/976_2.png) [@gcoladon](https://org-roam.discourse.group/u/gcoladon)\
**Post date:** [May 10, 2021, 3:15am UTC](https://org-roam.discourse.group/t/how-to-copy-the-org-protocol-roam-file-url-to-any-org-roam-file/1566/2 "2021-05-10T03:15:19Z")

</div>

> [@laotang](#):
>
> I was wondering how to create these URLs when I am in Emacs, visiting an org-roam file.

Just curious, what’s your use case for using org-protocol to go from org-mode file in Emacs to another org-mode file in Emacs?

---

<div class="post-metadata">

**Author:** ![laotang](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@laotang](https://org-roam.discourse.group/u/laotang)\
**Post date:** [May 10, 2021, 3:43am UTC](https://org-roam.discourse.group/t/how-to-copy-the-org-protocol-roam-file-url-to-any-org-roam-file/1566/3 "2021-05-10T03:43:34Z")

</div>

Oh, it is not for use within Emacs. These links allow to refer to org-roam files from other applications on macOS, for example Todoist, Zotero or even a Google Doc.

---

<div class="post-metadata">

**Author:** ![laotang](https://avatars.discourse-cdn.com/v4/letter/l/2acd7d/32.png) [@laotang](https://org-roam.discourse.group/u/laotang)\
**Post date:** [May 15, 2021, 6:33am UTC](https://org-roam.discourse.group/t/how-to-copy-the-org-protocol-roam-file-url-to-any-org-roam-file/1566/4 "2021-05-15T06:33:13Z")

</div>

This is the solution. Just in case anyone has the same needs 🙂

I use these links in Zotero and Todoist.

```auto
(defun my-copy-orgroam-URL-to-clipboard ()
  "Create a URL for the current orgroam file and copy it to the clipboard"
  (interactive)
  (let ((filename (if (equal major-mode 'dired-mode)
                      default-directory
                    (buffer-file-name))))
    (when filename
      (with-temp-buffer
       (insert (concat "org-protocol://roam-file?file=" filename))
        (clipboard-kill-region (point-min) (point-max)))
      (message "URL copied to clipboard"))))

```
