# Populate dropdown node help needed

**URL:** <https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725>\
**Category:** Dashboard\
**Created:** [27 February 2021 17:47 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725 "2021-02-27T17:47:12Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [27 February 2021 17:47 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725/1 "2021-02-27T17:47:12Z")

</div>

I want to populate the dashboard dropdown node with a list of whatever .jpg files are present in a folder which is located on a usb stick pugged into my pi, when I open the dropdown in the dashboard I want to be able to choose one of the file names in the drop down list and have it sent to the output of the dropdown node.  
I can get a list of files using the exec node with cmd ls /media/usbPEN/nas/snap/  
result is a string as see picture below...  
The problem I have is how do I populate the Value / Label field for each file name into the dropdown node.

Help would be appreciated.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/f/0f48454fbd375657652b688ec947cbb923d36d2d.png)

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [27 February 2021 18:03 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725/2 "2021-02-27T18:03:37Z")

</div>

There is `readdir` node, [node-red-contrib-readdir (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-readdir) which does the job all in one action . Reads the directory, puts result in array, and sets it to the `msg.options` so can be feed directly to the `dropdown` node.

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/f/8f404f5461afcb8bfe901dc2ff3ce52a9e6dbbe6.png)

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [27 February 2021 18:18 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725/3 "2021-02-27T18:18:40Z")

</div>

That sounds brilliant ill try that for sure .. thanks for your help.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [27 February 2021 18:25 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725/4 "2021-02-27T18:25:49Z")

</div>

I find the fs-ops node set better for file and directory operations.

You can get an array of files (with our without a wildcard) then pass that to the other fs-ops nodes to do other actions.

YMMV.

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [27 February 2021 18:31 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725/5 "2021-02-27T18:31:11Z")

</div>

hotNipi  
That `readdir` node is awesome, I've been scratching my head all afternoon trying things before I asked for help, thanks again for this info its brilliant, I am so happy..

Steve-Mci  
ill take a look at the fs-ops node tomorrow, the readdir node is going to take some beating though, thanks for your input.

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [28 February 2021 08:15 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725/6 "2021-02-28T08:15:06Z")

</div>

Me again .. I have one further question .. I want to send the directory path into the readdir node however I'm struggling to find a solution, unlike say the file nodes were you send msg.filename the Directory field cannot be left blank, I tried msg.payload {{msg.payload}} path, directory, dir in there but nothing appears to work , HOW ?

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/663b560fe534e10a05d98cc133897d9bbda6a6d0.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [28 February 2021 08:23 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725/7 "2021-02-28T08:23:27Z")

</div>

Did someone say fs-ops?

---

<div class="post-metadata">

**Author:** ![Dave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dave/32/10827_2.png) [@Dave](https://discourse.nodered.org/u/Dave)\
**Post date:** [28 February 2021 08:52 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725/8 "2021-02-28T08:52:23Z")

</div>

OK OK I've moved over to fs-ops successfully, only criticism the colour of the nodes are yuk, hahah

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [14 March 2021 08:53 UTC](https://discourse.nodered.org/t/populate-dropdown-node-help-needed/41725/9 "2021-03-14T08:53:06Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
