# Change filename for write Node dynamical and string change handling

**URL:** <https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430>\
**Category:** General\
**Created:** [17 October 2025 15:29 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430 "2025-10-17T15:29:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![reiry](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@reiry](https://discourse.nodered.org/u/reiry)\
**Post date:** [17 October 2025 15:29 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430/1 "2025-10-17T15:29:39Z")

</div>

So far, so good—I managed to do it in one day, but I'm a complete novice and come from LabView, where I can do something like this in 10 minutes... but anyway. Here's an example: my question is, is there any way to do this without a function node, especially when handling strings for the file name?  
function:  
msg.filename = '/home/rr/Dokumente/Logger/testloggera\_' + flow.get("NowDate") + '.txt';  
return msg;

```auto
[
    {
        "id": "3ad48c473fea5513",
        "type": "function",
        "z": "80ea8d142ccb0bd4",
        "name": "setze filename mit NowDate neu zusammen",
        "func": " msg.filename = '/home/rr/Dokumente/Logger/testloggera_' + flow.get(\"NowDate\") + '.txt';\n return msg;\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 850,
        "y": 500,
        "wires": [
            [
                "b37f712221ebfe5f",
                "1dfaff9af10ddb0e",
                "806a9b21564b40f0"
            ]
        ]
    }

]

```

 ![Bildschirmfoto vom 2025-10-17 17-36-45](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/c/3c1991d91da10ba55fc3aeab08c77bcc4cc97b41.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 October 2025 15:48 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430/2 "2025-10-17T15:48:11Z")

</div>

You could use Jsonata in a change node

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/b/2b03efb967d6dd97867fde8bbd107c6e0c6678a1.png)

```auto
[{"id":"0d1266049d9698cf","type":"change","z":"d14258870cbe9738","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"'/home/rr/Dokumente/Logger/testloggera_' & $flowContext(\"NowDate\") & '.txt'","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":225,"wires":[["6526a6d0ad6fbad0"]]}]

```

---

<div class="post-metadata">

**Author:** ![reiry](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@reiry](https://discourse.nodered.org/u/reiry)\
**Post date:** [17 October 2025 15:51 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430/3 "2025-10-17T15:51:31Z")

</div>

Yes i now 😅 but is it without any scripting possible?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 October 2025 16:18 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430/4 "2025-10-17T16:18:26Z")

</div>

You could use mustache syntax in a template node but NowDate would have to be a message property rather than a flow context variable. (Why are you using a flow context variable anyway?)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/6076287f7cc866e33274b5dc6a849fe0c38dffcc.png)

---

<div class="post-metadata">

**Author:** ![reiry](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@reiry](https://discourse.nodered.org/u/reiry)\
**Post date:** [17 October 2025 17:38 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430/5 "2025-10-17T17:38:50Z")

</div>

One of the big mysteries for me is the use of templates and what a mustach is—what a funny name. I've only shown an excerpt of my project here. The variable flow.NowDate is used elsewhere as a decision maker...  
But thanks again, I'm coming from LabView where everything works without scripting! But LV has its quirks too... me hoppe is/was also NR is script free, 😉

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [17 October 2025 18:12 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430/6 "2025-10-17T18:12:44Z")

</div>

The name mustache clearly derives from it's use in this (admittedly uncommon) smiley :-{)

A really big mystery is how the ! came to be called Bang!

I've never heard of LabView. How would you concatenate the strings in that?

> [@reiry](#):
>
> The variable flow.NowDate is used elsewhere as a decision maker.

This is not a very Node-red approach, though of course it is possible to code it like this.  
A flow context variable can be changed at any time by the arrival of a new message.  
The Node-red approach would be to generate the value and attach it as a message property. Then the value is passed along the flow\* and is unaffected by a new input

`*` Most nodes follow the rule of passing on such message properties unaffected. Some contrib nodes fail to do this.

---

<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:** [17 October 2025 18:35 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430/7 "2025-10-17T18:35:30Z")

</div>

> [@reiry](#):
>
> me hoppe is/was also NR is script free,

You can do this in the change node without scripting, but why not use JSONata direct in file write node?

example of change node with no scripting

```auto
[{"id":"0d1266049d9698cf","type":"change","z":"613df62afc8a16bf","name":"","rules":[{"t":"set","p":"filename","pt":"msg","to":"/home/rr/Dokumente/Logger/testloggera_*#*.txt","tot":"str"},{"t":"set","p":"NowDate","pt":"msg","to":"NowDate","tot":"flow"},{"t":"change","p":"filename","pt":"msg","from":"*#*","fromt":"str","to":"NowDate","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":80,"wires":[["e99af74c636b45c0"]]}]

```

---

<div class="post-metadata">

**Author:** ![reiry](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@reiry](https://discourse.nodered.org/u/reiry)\
**Post date:** [29 October 2025 08:43 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430/8 "2025-10-29T08:43:27Z")

</div>

thx @E1cid cool string solution: but, the idea is to use the flow variable for the next incoming message in comparison, since the flow variable is kept constant... which currently works, but strangely enough, I can't display the variable in the contxt view, which is odd? With the debug Node and Jeson : $flowContext("neudate") get undefind (Rasberry/Linux)? But in Test Mode on Linux PC it works...  
@jbudd Labview you can real works only with Icons without any Scripting the complex project wath i have ever seen was an Helicopter-Test landing without a Pilot 😉 ...

---

<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:** [12 November 2025 08:43 UTC](https://discourse.nodered.org/t/change-filename-for-write-node-dynamical-and-string-change-handling/99430/9 "2025-11-12T08:43:37Z")

</div>

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