Limitation in filter on FS LIST and FS-OPS-DIR

I have the same problem in both named nodes and wondering if anyone as a solution or documentation that explains the problem.

I have files which have parenthesis in their filename but those are never found when I search for them.
If I try to list the whole content of a folder they are found in the file list array but when I use parenthesis in the filter, they aren't found.

Without looking at how the filtering is done (e.g. regex / glob etc) your options are limited to:

  1. Do it yourself using fs
  2. Do a secondary filter yourself (e.g. msg.payload = msg.files.filter(e => /[()]/.test(e)) )
  3. raise an issue on the nodes asking for clarification and / or support finding special characters.

Demo

[{"id":"0d274cc377e7f340","type":"fs-ops-dir","z":"c2233fc1d8cc5c3b","name":"","path":"c:/temp","pathType":"str","filter":"*.jpg","filterType":"str","dir":"files","dirType":"msg","x":250,"y":1020,"wires":[["ca22c32c2e75240c","4017b79b997d447d"]]},{"id":"ca5b9642a534ca2a","type":"inject","z":"c2233fc1d8cc5c3b","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":1020,"wires":[["0d274cc377e7f340"]]},{"id":"ca22c32c2e75240c","type":"debug","z":"c2233fc1d8cc5c3b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"files","targetType":"msg","statusVal":"","statusType":"auto","x":580,"y":1020,"wires":[]},{"id":"4017b79b997d447d","type":"function","z":"c2233fc1d8cc5c3b","name":"has paren?","func":"msg.payload = msg.files.filter(e => /[()]/.test(e))\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":1100,"wires":[["a3fd82c83d8186c7"]]},{"id":"a3fd82c83d8186c7","type":"debug","z":"c2233fc1d8cc5c3b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":1100,"wires":[]}]

Can you show us what you are entering please and the names of files that it is not finding, so that we can test it.

I have two files in the folder:
test_new_PressTalk_jch - Copy (7).OL-package
test_new_PressTalk_jch - Copy (7)_report.zip

The filter is
test_new_PressTalk_jch - Copy (7)

It is necessary to escape the the parenthesis. Try this
test_new_PressTalk_jch - Copy \(7\)

Edit, also you will need a * on the end, otherwise it will find only exact matching files, not the ones with extra text on the end.
test_new_PressTalk_jch - Copy \(7\)*

That seems to work when I use the mask directly in the field but I am having problem setting the mask insisde a msg.payload.filenamemask variable. Any tips?

I am trying to do it via JSONATA like this:

$replace($replace($.payload.filename,'/[(]/g','\('),'/[)]/g','\)')

Sorry, I don't do jsonata

The regex would be

$replace($$.payload.filename,/([(|)])/,'\\$1')

Or to only test for (number)

$replace($$.payload.filename,/(\(\d+)(\))/,'\\$1\\$2')

Thank you so much ALL...it works! :wink:

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