Fs-file-lister is not working

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.

MobaXterm_Personal_20.6_9Qfw5FumTO

What am I doing wrong?

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?

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

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

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

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

@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'

No additional dependencies.

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

  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.

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

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.

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

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.

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

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.

@el_pablo well I get the same results using 1.3.5

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

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

1 Like

@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. :sneezing_face:

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.

// 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

2 Likes