# Setting directory in "watcher" from context variable

**URL:** <https://discourse.nodered.org/t/setting-directory-in-watcher-from-context-variable/66811>\
**Category:** General\
**Created:** [23 August 2022 12:36 UTC](https://discourse.nodered.org/t/setting-directory-in-watcher-from-context-variable/66811 "2022-08-23T12:36:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kristvanbesien](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kristvanbesien/32/66697_2.png) [@kristvanbesien](https://discourse.nodered.org/u/kristvanbesien)\
**Post date:** [23 August 2022 12:36 UTC](https://discourse.nodered.org/t/setting-directory-in-watcher-from-context-variable/66811/1 "2022-08-23T12:36:55Z")

</div>

I have been playing around with node red for a few days now. And there is something I cannot figure out. So I ask it here.

There exists a "watcher" node (as well as several variants, like "watcher directory" that you can use to watch a directory for changes, and then do something with the files. To configure it you need to set a "Files(s)" property which is just a string.

I do not like to statically code properties this way, as I plan on using this node a few times with the same value, and I like to keep things DRY.

So is there a way to refer to a context variable there in some way? I have been looking for information if I can interpolate variables there, but so far without success.

So is there a way?

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [23 August 2022 12:52 UTC](https://discourse.nodered.org/t/setting-directory-in-watcher-from-context-variable/66811/2 "2022-08-23T12:52:17Z")

</div>

You can use an externally set environment variable [Using environment variables : Node-RED](https://nodered.org/docs/user-guide/environment-variables) - or you can use one watcher node then `link` nodes to move the event to the other parts of your flow that need it.

---

<div class="post-metadata">

**Author:** ![kristvanbesien](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kristvanbesien/32/66697_2.png) [@kristvanbesien](https://discourse.nodered.org/u/kristvanbesien)\
**Post date:** [23 August 2022 13:22 UTC](https://discourse.nodered.org/t/setting-directory-in-watcher-from-context-variable/66811/3 "2022-08-23T13:22:34Z")

</div>

Thanks. That worked, but it was not entirely the solution I wash hoping for.

Maybe I need to look for a better directory watchers. I have been playing around with node-red-contrib-watchdirectory-recursive but it has the disadvantage that I cannot tell it to watch for all events. So I need to instantiate three of them. And I was hoping that I cold configure them with a context variable that then would be initialized using a config node.

---

<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:** [22 October 2022 13:23 UTC](https://discourse.nodered.org/t/setting-directory-in-watcher-from-context-variable/66811/4 "2022-10-22T13:23:18Z")

</div>

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