# How to add links to random notes to daily note

**URL:** <https://forum.obsidian.md/t/how-to-add-links-to-random-notes-to-daily-note/52379>\
**Category:** Help\
**Created:** [January 15, 2023, 3:27pm UTC](https://forum.obsidian.md/t/how-to-add-links-to-random-notes-to-daily-note/52379 "2023-01-15T15:27:32Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![holroy](https://forum.obsidian.md/user_avatar/forum.obsidian.md/holroy/32/77699_2.png) [@holroy](https://forum.obsidian.md/u/holroy)\
**Post date:** [January 16, 2023, 3:13pm UTC](https://forum.obsidian.md/t/how-to-add-links-to-random-notes-to-daily-note/52379/6 "2023-01-16T15:13:09Z")

</div>

I guess you didn’t see the note I made on `tR`, or understood it, for the following code only stores the result of the code into your new note:

```auto
<%* 
const noOfNotes = 5
const files = app.vault.getFiles()

for (let i = 0; i < noOfNotes; i++) {
  const random = Math.floor(Math.random() * 
                            (files.length - 1))
  const randomNote = files[random]
    
  tR += `- [[${randomNote.path} | ${ randomNote.basename }]]\n`
}
%>

```

I’ve also included the option to specify how many random notes you want by changing the first line to whatever number of random notes you want.

---

_[View the full topic](https://forum.obsidian.md/t/how-to-add-links-to-random-notes-to-daily-note/52379)._
