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

**URL:** <https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210>\
**Category:** General\
**Created:** [2 January 2024 15:14 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210 "2024-01-02T15:14:58Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jhamel](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jhamel](https://discourse.nodered.org/u/jhamel)\
**Post date:** [2 January 2024 15:14 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/1 "2024-01-02T15:14:58Z")

</div>

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.

---

<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:** [2 January 2024 15:46 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/2 "2024-01-02T15:46:34Z")

</div>

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

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

```auto
[{"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":[]}]

```

---

<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:** [2 January 2024 16:07 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/4 "2024-01-02T16:07:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jhamel](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jhamel](https://discourse.nodered.org/u/jhamel)\
**Post date:** [2 January 2024 16:42 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/5 "2024-01-02T16:42:59Z")

</div>

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)

---

<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:** [2 January 2024 17:18 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/6 "2024-01-02T17:18:26Z")

</div>

> [@jhamel](#):
>
> 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\)*`

---

<div class="post-metadata">

**Author:** ![jhamel](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jhamel](https://discourse.nodered.org/u/jhamel)\
**Post date:** [2 January 2024 17:25 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/7 "2024-01-02T17:25:36Z")

</div>

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','\)')

---

<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:** [2 January 2024 17:48 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/8 "2024-01-02T17:48:10Z")

</div>

Sorry, I don't do jsonata

---

<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:** [2 January 2024 17:49 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/9 "2024-01-02T17:49:41Z")

</div>

The regex would be

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

```

Or to only test for (number)

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

```

---

<div class="post-metadata">

**Author:** ![jhamel](https://avatars.discourse-cdn.com/v4/letter/j/76d3ee/32.png) [@jhamel](https://discourse.nodered.org/u/jhamel)\
**Post date:** [2 January 2024 18:01 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/10 "2024-01-02T18:01:48Z")

</div>

Thank you so much ALL...it works! 😉

---

<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:** [2 March 2024 18:02 UTC](https://discourse.nodered.org/t/limitation-in-filter-on-fs-list-and-fs-ops-dir/84210/11 "2024-03-02T18:02:41Z")

</div>

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