# How to use "Watch" only for .txt and .xml

**URL:** <https://discourse.nodered.org/t/how-to-use-watch-only-for-txt-and-xml/87639>\
**Category:** General\
**Created:** [2 May 2024 07:27 UTC](https://discourse.nodered.org/t/how-to-use-watch-only-for-txt-and-xml/87639 "2024-05-02T07:27:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Perkele](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@Perkele](https://discourse.nodered.org/u/Perkele)\
**Post date:** [2 May 2024 07:27 UTC](https://discourse.nodered.org/t/how-to-use-watch-only-for-txt-and-xml/87639/1 "2024-05-02T07:27:44Z")

</div>

Hello everyone,  
I use the “Watch” command to monitor a directory including its subdirectories.  
As soon as it reads data from the subdirectories I get the error message. "Error: EISDIR: illegal operation on a directory, read"

Is there a way to only monitor .xml and .txt files?  
BR Perkele

---

<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 May 2024 07:57 UTC](https://discourse.nodered.org/t/how-to-use-watch-only-for-txt-and-xml/87639/2 "2024-05-02T07:57:23Z")

</div>

> [@Perkele](#):
>
> I use the “Watch” command to monitor a directory including its subdirectories.  
> As soon as it reads data from the subdirectories I get the error message. "Error: EISDIR: illegal operation on a directory, read"

Exactly what Watch command are you using?

As soon as what reads from the subdirectories.

Also please show us the startup log from node-red, that will tell us a lot about your system.

---

<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 May 2024 07:59 UTC](https://discourse.nodered.org/t/how-to-use-watch-only-for-txt-and-xml/87639/3 "2024-05-02T07:59:07Z")

</div>

You can simply watch the directory and use a switch node after the watch to filter the `.xml` and `.txt` files

![chrome_sfDYLUIr4P](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/1/01d21c8885a7ac1d2f17890f882ed2709618ec02.gif)

Demo flow (use `CTRL+I` to import it)

```auto
[{"id":"6fdfaaf255b50a10","type":"watch","z":"3642c7ee286f9c17","name":"","files":"c:/temp/","recursive":true,"x":1290,"y":260,"wires":[["6072ba90a762695a"]]},{"id":"6072ba90a762695a","type":"switch","z":"3642c7ee286f9c17","name":"","property":"filename","propertyType":"msg","rules":[{"t":"regex","v":"\\.txt$","vt":"str","case":false},{"t":"regex","v":"\\.xml$","vt":"str","case":false}],"checkall":"true","repair":false,"outputs":2,"x":1590,"y":260,"wires":[["e337f5a1709a6001"],["aae583f0053d1803"]]},{"id":"442f6f3a11522f39","type":"inject","z":"3642c7ee286f9c17","name":"filename: test1.txt","props":[{"p":"payload"},{"p":"filename","v":"test1.txt","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1320,"y":20,"wires":[["fb07d3fdd7b9f2ce"]]},{"id":"e9e772d7436bb193","type":"inject","z":"3642c7ee286f9c17","name":"filename: test1.txt.zip","props":[{"p":"payload"},{"p":"filename","v":"test1.txt.zip","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1340,"y":100,"wires":[["fb07d3fdd7b9f2ce"]]},{"id":"4972b130870b365f","type":"inject","z":"3642c7ee286f9c17","name":"filename: test1.pdf","props":[{"p":"payload"},{"p":"filename","v":"test1.pdf","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1330,"y":140,"wires":[["fb07d3fdd7b9f2ce"]]},{"id":"113a52d49a3a6226","type":"inject","z":"3642c7ee286f9c17","name":"filename: test1.xml","props":[{"p":"payload"},{"p":"filename","v":"test1.xml","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1330,"y":180,"wires":[["fb07d3fdd7b9f2ce"]]},{"id":"e337f5a1709a6001","type":"debug","z":"3642c7ee286f9c17","name":"txt files -> ","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"filename","statusType":"msg","x":1740,"y":220,"wires":[]},{"id":"aae583f0053d1803","type":"debug","z":"3642c7ee286f9c17","name":"xml files -> ","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"filename","statusType":"msg","x":1750,"y":300,"wires":[]},{"id":"33beb950e5066b5c","type":"inject","z":"3642c7ee286f9c17","name":"filename: test2.txt","props":[{"p":"payload"},{"p":"filename","v":"test2.txt","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1320,"y":60,"wires":[["fb07d3fdd7b9f2ce"]]},{"id":"13fb944742cce589","type":"inject","z":"3642c7ee286f9c17","name":"filename: test2.xml","props":[{"p":"payload"},{"p":"filename","v":"test2.xml","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1330,"y":220,"wires":[["fb07d3fdd7b9f2ce"]]},{"id":"fb07d3fdd7b9f2ce","type":"junction","z":"3642c7ee286f9c17","x":1500,"y":80,"wires":[["6072ba90a762695a"]]}]

```

---

<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:** [31 July 2024 07:59 UTC](https://discourse.nodered.org/t/how-to-use-watch-only-for-txt-and-xml/87639/4 "2024-07-31T07:59:44Z")

</div>

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