# How to automatically change file name based in a variable "job number"

**URL:** <https://discourse.nodered.org/t/how-to-automatically-change-file-name-based-in-a-variable-job-number/38723>\
**Category:** General\
**Created:** [7 January 2021 15:24 UTC](https://discourse.nodered.org/t/how-to-automatically-change-file-name-based-in-a-variable-job-number/38723 "2021-01-07T15:24:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jjam89031](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jjam89031](https://discourse.nodered.org/u/jjam89031)\
**Post date:** [7 January 2021 15:24 UTC](https://discourse.nodered.org/t/how-to-automatically-change-file-name-based-in-a-variable-job-number/38723/1 "2021-01-07T15:24:55Z")

</div>

I have my flow collecting a "job number" and other data automatically from a machine, all converted into a CSV using the CSV node and feed to an SMB node to create an Excell file in a shared drive in a server automatically when the job is finished. Node-red is not running on a local PC, the shared drive requires authentication "IP, username, password", therefore I can't use the regular file nodes, anyways the SMB node is set up properly to the point the file is created with a name that I manually enter into the SMB file with no problem at all.  
But the idea is that upon each new "job number" the file will be named to that "job number", thus creating the different job number files required automatically. I understand this has to be done in a function node using javascript or JASONata, but I'm not a programmer by any means. So if there's anybody that can help me with this I really appreciated it, it is basically the last step of my project.  
Thanks.

---

<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:** [7 January 2021 15:45 UTC](https://discourse.nodered.org/t/how-to-automatically-change-file-name-based-in-a-variable-job-number/38723/2 "2021-01-07T15:45:01Z")

</div>

Here is a recent example of changing a filename.  
[How to insert a "variable string" into "FILENAME" topic of "FILE IN" node? - #3 by luks](https://discourse.nodered.org/t/how-to-insert-a-variable-string-into-filename-topic-of-file-in-node/38672/4) If you want more help you will need to supply more info.

---

<div class="post-metadata">

**Author:** ![jjam89031](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@jjam89031](https://discourse.nodered.org/u/jjam89031)\
**Post date:** [7 January 2021 21:24 UTC](https://discourse.nodered.org/t/how-to-automatically-change-file-name-based-in-a-variable-job-number/38723/3 "2021-01-07T21:24:04Z")

</div>

> [@jjam89031](#):
>
> Node-red is not running on a local PC

like what info ?

---

<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:** [7 January 2021 21:30 UTC](https://discourse.nodered.org/t/how-to-automatically-change-file-name-based-in-a-variable-job-number/38723/4 "2021-01-07T21:30:57Z")

</div>

What the input looks like  
what the output should look like  
what your flow looks like.

---

<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:** [7 January 2021 21:54 UTC](https://discourse.nodered.org/t/how-to-automatically-change-file-name-based-in-a-variable-job-number/38723/6 "2021-01-07T21:54:49Z")

</div>

Your flow is corrupt.  
please read

> [@How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506):
>
> To share code samples or flow json in this forum, you need to take care to format it properly so that it is displayed correctly. The easiest way to do that is to click the 'Preformatted Text' button in the toolbar: [image] Then paste in your code or flow json. You should end up with three back-tick characters - ``` - on their own line before and after the code. On standard US English keyboards, this is on the same key as the ~ character. Using the backticks will ens…

I will also need what the inputs are asand what you want the output to loko like.  
please add some debug outputs of the inputs, etc

---

<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:** [9 March 2021 14:29 UTC](https://discourse.nodered.org/t/how-to-automatically-change-file-name-based-in-a-variable-job-number/38723/13 "2021-03-09T14:29:07Z")

</div>

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