# Fs-file-lister is not working

**URL:** <https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731>\
**Category:** General\
**Created:** [8 September 2021 00:51 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731 "2021-09-08T00:51:06Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![el\_pablo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/el_pablo/32/45496_2.png) [@el\_pablo](https://discourse.nodered.org/u/el_pablo)\
**Post date:** [8 September 2021 00:51 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/1 "2021-09-08T00:51:06Z")

</div>

Hi guys,

I'm trying to figure out how to make fs-file-lister to work, but it always return 0 even though there's a file named _test.txt_ and a subfolder named _dump_ in the folder I'm looking into.

 ![firefox_G2fb9mjABP](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/1/31721e67a9f324197d9f52c5e425a51c15ccbda3.png)

![MobaXterm_Personal_20.6_9Qfw5FumTO](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/13e263a6a3365259bb011a0a8fb93d5e52b032f0.png)

What am I doing wrong?

---

<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:** [8 September 2021 01:24 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/2 "2021-09-08T01:24:03Z")

</div>

It work for me, though it does not find files whose names _Edit - DON'T_ include a dot, unless I change File Pattern to two asterisks with no dot.

Is datalog a straightforward directory rather than a link or mount point?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [8 September 2021 20:17 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/3 "2021-09-08T20:17:31Z")

</div>

> [@jbudd](#):
>
> though it does not find files whose names include a dot, unless I change File Pattern to two asterisks with no dot.

It is on my list of things to fix when I get some time. Or someone could do a PR 🙂

---

<div class="post-metadata">

**Author:** ![el\_pablo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/el_pablo/32/45496_2.png) [@el\_pablo](https://discourse.nodered.org/u/el_pablo)\
**Post date:** [10 September 2021 00:54 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/4 "2021-09-10T00:54:40Z")

</div>

Even when I type \*.\* the result is still an empty array. Is there any dependencies?

---

<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:** [10 September 2021 01:35 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/5 "2021-09-10T01:35:26Z")

</div>

A possible work-around:  
an Exec node to call **find /home/pi/datalog -maxdepth 1 -type f**  
and a Function to format it as an array

```auto
var arr = msg.payload.split("\n");
if (arr[arr.length-1] === "") {
    arr.pop();
}
msg.payload = arr;
return msg;

```

No idea if it will exhibit the same issue for you as fs-file-lister

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 September 2021 09:36 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/6 "2021-09-10T09:36:53Z")

</div>

@el_pablo

1. what version of NR and node.js are you running? (see startup log)
2. what version of node-red-contrib-fs are you running? You can use the 'Manage Palette' from the hamburger menu (top right of the editor) to find out.
3. what model Pi are you running? - Use 'cat /proc/device-tree/model'
4. what os are you running? - use 'cat /etc/os-release'

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [10 September 2021 13:47 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/7 "2021-09-10T13:47:27Z")

</div>

No additional dependencies.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 September 2021 14:02 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/8 "2021-09-10T14:02:02Z")

</div>

In addition to @zenofmud's questions, how did you install node-red? Are you using a Docker or Home Assistant version for example?

---

<div class="post-metadata">

**Author:** ![el\_pablo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/el_pablo/32/45496_2.png) [@el\_pablo](https://discourse.nodered.org/u/el_pablo)\
**Post date:** [10 September 2021 15:45 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/9 "2021-09-10T15:45:59Z")

</div>

1. My NR version is 1.3.5 and Node is v12.18.3
2. Node-red-contrib-fs is 1.4.1
3. Pi 3B rev 1.2
4. Raspbian GNU/Linux 9 (stretch)

@Colin I'm running NR on my raspberry-pi which is a standalone installation. Docker is not installed.

I'm also running OctoPi on it to manage my 3D printer.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 September 2021 16:10 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/10 "2021-09-10T16:10:48Z")

</div>

> [@el\_pablo](#):
>
> I'm running NR on my raspberry-pi which is a standalone installation

You didn't say how you installed node-red. Are you using the default install? That is out of date and you are using an old version of nodejs too. I suggest upgrading to the latest node-red using the [recommended pi install/upgrade script](https://nodered.org/docs/getting-started/raspberrypi)

Add the option `--node14` on the end of the line to install nodejs v14.

Make sure all installed nodes are up to date first (using Manage Palette). Also it is a good idea to upgrade other packages on your system using  
`sudo apt-get update && sudo apt-get dist-upgrade`

The upgrade may not help but then you will be using the same version as others here and you can rule that out as a possibility. Obviously backup anything important before running tasks such as this.

---

<div class="post-metadata">

**Author:** ![el\_pablo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/el_pablo/32/45496_2.png) [@el\_pablo](https://discourse.nodered.org/u/el_pablo)\
**Post date:** [10 September 2021 16:53 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/11 "2021-09-10T16:53:10Z")

</div>

There are the commands I used to install NR at the time.

```auto
bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
npm install node-red-dashboard

```

I'll will update everything as you said.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 September 2021 17:03 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/12 "2021-09-10T17:03:43Z")

</div>

So I just tried it on a Pi and this is what I got:

 ![Screen Shot 2021-09-10 at 12.59.28 PM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/1/110c45582b5208c21625fcc4a74a2a1f807acb98.jpeg)

This was running with node.js 10.24.0 and NR v1.2.9 I'll upgrade it to 1.3.5 and see what happens.

One thing I did notice is your test.txt file is zero bytes long but then again one of my two files is zero bytes long too.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 September 2021 19:22 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/13 "2021-09-10T19:22:16Z")

</div>

@el_pablo well I get the same results using 1.3.5

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 September 2021 19:26 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/14 "2021-09-10T19:26:03Z")

</div>

> [@el\_pablo](#):
>
> There are the commands I used to install NR at the time.
> 
> ```auto
> bash <(curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered)
> bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
> npm install node-red-dashboard
> 
> ```

why are you running two different bash commands? for the Pi you should oly run the first one.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 September 2021 20:03 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/15 "2021-09-10T20:03:27Z")

</div>

> [@zenofmud](#):
>
> for the Pi you should oly run the first one.

It's the second one actually. I think the first was an earlier version.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [10 September 2021 20:19 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/16 "2021-09-10T20:19:56Z")

</div>

@colin, yup you are right! I blame all my errors on the head cold my one year old grandaughter gave me this week. That's my story and I'm stickking to it. 🤧

---

<div class="post-metadata">

**Author:** ![el\_pablo](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/el_pablo/32/45496_2.png) [@el\_pablo](https://discourse.nodered.org/u/el_pablo)\
**Post date:** [11 September 2021 14:19 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/17 "2021-09-11T14:19:32Z")

</div>

I'm new to NR and I'm dumb. I found out what was wrong. I had a brain fart.

I forgot that I was feeding a pattern into the node, which I forgot to mention... My code was looking for a specific file and my brain only wanted to test the node.

I have a function node that was feeding the fs-file-lister node.

```auto
// Get the current time and convert it to text
var now = new Date();
var yyyy = now.getFullYear();
var mm = now.getMonth() < 9 ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based
var dd = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();
var hh = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
var mmm = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
var ss = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();

// Generate out file name pattern
msg.fname = "bioreact_"+ yyyy + mm + dd + ".csv";
// Full filename with path for the file node later
msg.filename = "/home/pi/datalog/"+ msg.fname;

// We save the current payload into a different place on the msg object
msg.filecontent = msg.payload;

// We are passing the file name search pattern to fs node to tell us if the file exists or not
msg.payload = {"pattern":msg.fname};

node.status({fill:"blue",shape:"ring",text:msg.fname});
return msg;

```

No wonder I thought it wasn't working...

Thanks for your help

---

<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:** [25 September 2021 14:19 UTC](https://discourse.nodered.org/t/fs-file-lister-is-not-working/50731/18 "2021-09-25T14:19:39Z")

</div>

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