# Refile entries/nodes between org files and org-roam notes

**URL:** <https://org-roam.discourse.group/t/refile-entries-nodes-between-org-files-and-org-roam-notes/1484>\
**Category:** Tips\
**Created:** [April 18, 2021, 12:02pm UTC](https://org-roam.discourse.group/t/refile-entries-nodes-between-org-files-and-org-roam-notes/1484 "2021-04-18T12:02:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![midas](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@midas](https://org-roam.discourse.group/u/midas)\
**Post date:** [April 18, 2021, 12:02pm UTC](https://org-roam.discourse.group/t/refile-entries-nodes-between-org-files-and-org-roam-notes/1484/1 "2021-04-18T12:02:49Z")

</div>

For a variety of reasons, I often need to refile nodes/entries between org-roam files and my other org files (e.g., org-agenda-files). I find the following accomplishes this and I am posting in case others have a similar need :

```auto
  (setq myroamfiles (directory-files "~/path/to/my/roam/notes" t "org$"))

  ;; -------- refile settings -----
  (setq org-refile-targets '((org-agenda-files :maxlevel . 5) (myroamfiles :maxlevel . 5)))
  (setq org-refile-use-outline-path 'file)
  (setq org-outline-path-complete-in-steps nil)
  (setq org-refile-allow-creating-parent-nodes 'confirm)

```

The code is based on [Aaron Bieber’s excellent post](https://blog.aaronbieber.com/2017/03/19/organizing-notes-with-refile.html) for setting up org-refile. My addendum is the inclusion of `myroamfiles`.

EDIT: During a normal session, one creates many org-roam files. (I also cull org-roam files). These changes are not reflected “live” in `myroamfiles` and therefore `org-refile` does not provide up-to-date options of target entries for refiling. It seems that a hook(?) could be added to the function that updates the org-roam-db. The hook would do the following: if `num-org-roam-files` has changed, then redefine/reset `myroamfiles` and `org-refile-targets`.
