# List files local directory (file name Strings)

**URL:** <https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915>\
**Category:** General\
**Tags:** node-red-dashboard\
**Created:** [11 March 2025 07:21 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915 "2025-03-11T07:21:32Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![itolond](https://avatars.discourse-cdn.com/v4/letter/i/c37758/32.png) [@itolond](https://discourse.nodered.org/u/itolond)\
**Post date:** [11 March 2025 07:21 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/1 "2025-03-11T07:21:32Z")

</div>

New to Node Red  
created a flow with a readdir node - debug indicates the node is picking up all the files in the directory as a complete path (all good here)  
What I am not sure of is how to make this a **drop down (single choice)** with just the file names no directory information (even better with a .XXX extension filter for MP4 file types)

unsure of how to execute this?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [11 March 2025 07:45 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/2 "2025-03-11T07:45:30Z")

</div>

Hi and welcome.

> [@itolond](#):
>
> execute this?

This is very vague, you do not mention what the data is, string, array or object etc. You really should supply an example of the data. Also is this dropdown displaying just a file name but outputting the complete path?  
Please show us the output require from the input supplied.

---

<div class="post-metadata">

**Author:** ![itolond](https://avatars.discourse-cdn.com/v4/letter/i/c37758/32.png) [@itolond](https://discourse.nodered.org/u/itolond)\
**Post date:** [11 March 2025 08:04 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/3 "2025-03-11T08:04:23Z")

</div>

Execute can be vague.

String array

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [11 March 2025 08:27 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/4 "2025-03-11T08:27:29Z")

</div>

Still none of the information requested, I will ask one more time for an example of the data and output.

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path/value for any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [11 March 2025 08:31 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/5 "2025-03-11T08:31:32Z")

</div>

> [@itolond](#):
>
> Execute can be vague.

Yup.

As I understand it you want a list of MP4 files in a given directory, but not the full pathname?

I'd do it with an exec node `ls /home/ian/media/*.mp4` or `cd /home/ian/media/; ls *.mp4` but then I use Linux. I dare say other operating systems offer similar functions.

---

<div class="post-metadata">

**Author:** ![itolond](https://avatars.discourse-cdn.com/v4/letter/i/c37758/32.png) [@itolond](https://discourse.nodered.org/u/itolond)\
**Post date:** [11 March 2025 08:59 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/6 "2025-03-11T08:59:35Z")

</div>

Currently I get a list of strings which includes the file name as well as the full Path

Only the file name is critical. As the directories are synced with a remote machine. Which is looking only the file name as it already knows the path to pickup the file.

The impetus behind getting a file list and selecting one is to ensure 1 the file should exist on the remote machine, and the file name matches exactly.

Hope that explains it

---

<div class="post-metadata">

**Author:** ![itolond](https://avatars.discourse-cdn.com/v4/letter/i/c37758/32.png) [@itolond](https://discourse.nodered.org/u/itolond)\
**Post date:** [11 March 2025 19:57 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/7 "2025-03-11T19:57:15Z")

</div>

this is the degug window and the array from the node [file lister]

["Defaultvideo.mp4","HDTV pattern.jpg","hummingbird.mp4","PostVideo.mp4","Prevideo.mp4"]

the next step is to have this data display as choices in a dropdown UI node -this will be used to construct a msg to the remote manchine

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [11 March 2025 20:22 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/8 "2025-03-11T20:22:22Z")

</div>

Without the full info i asked for and answers to the questions i asked i can only offer this example.

Hope it helps, it should create an options array for node-red-dashboard, containing only mp4 file names.

```auto
[{"id":"0c6a37e001738edf","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"Defaultvideo.mp4\",\"HDTV pattern.jpg\",\"hummingbird.mp4\",\"PostVideo.mp4\",\"Prevideo.mp4\"]","payloadType":"json","x":230,"y":5600,"wires":[["a881122d87f140df"]]},{"id":"a881122d87f140df","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"options","pt":"msg","to":"$$.payload[$substring($, -4) = \".mp4\"].{$:$}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":5600,"wires":[["48856e2089e8c664","4ff46e05d0f1a28c"]]},{"id":"48856e2089e8c664","type":"debug","z":"d1395164b4eec73e","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":600,"y":5600,"wires":[]},{"id":"4ff46e05d0f1a28c","type":"ui_dropdown","z":"d1395164b4eec73e","name":"","label":"","tooltip":"","place":"Select option","group":"2d4fe667.28f8ba","order":1,"width":0,"height":0,"passthru":true,"multiple":false,"options":[{"label":"","value":"","type":"str"}],"payload":"","topic":"topic","topicType":"msg","className":"","x":540,"y":5640,"wires":[[]]},{"id":"2d4fe667.28f8ba","type":"ui_group","name":"Demo","tab":"0ca01f1e15e69b4d","order":2,"disp":true,"width":"18","collapse":false,"className":""},{"id":"0ca01f1e15e69b4d","type":"ui_tab","name":"demo","icon":"dashboard","disabled":false,"hidden":false}]

```

[How to import/export a flow](https://nodered.org/docs/user-guide/editor/workspace/import-export)

---

<div class="post-metadata">

**Author:** ![itolond](https://avatars.discourse-cdn.com/v4/letter/i/c37758/32.png) [@itolond](https://discourse.nodered.org/u/itolond)\
**Post date:** [12 March 2025 00:13 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/9 "2025-03-12T00:13:47Z")

</div>

worked a treat thx

---

<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:** [26 March 2025 00:14 UTC](https://discourse.nodered.org/t/list-files-local-directory-file-name-strings/95915/10 "2025-03-26T00:14:08Z")

</div>

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