# New name for every picture

**URL:** <https://discourse.nodered.org/t/new-name-for-every-picture/75089>\
**Category:** General\
**Created:** [12 February 2023 20:50 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089 "2023-02-12T20:50:37Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![agassparkle](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@agassparkle](https://discourse.nodered.org/u/agassparkle)\
**Post date:** [12 February 2023 20:50 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/1 "2023-02-12T20:50:37Z")

</div>

Hello ,

I am trying to give motion triggered pictures different names. I don't want them to be over written.

I have this flow which saves the pictures but couldn't figure out how to give different names.

```auto
[{"id":"4416b46d00b74e1d","type":"server-state-changed","z":"7aa5b5b5.c7c5f8","name":"Motion Sensor","server":"30307a46.24469a","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.192_168_50_60_motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"2","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":140,"y":60,"wires":[["ddcf9a5fdc523cf8"]]},{"id":"ddcf9a5fdc523cf8","type":"switch","z":"7aa5b5b5.c7c5f8","name":"Value > 60?","property":"data.new_state.state","propertyType":"msg","rules":[{"t":"gt","v":"60","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":310,"y":60,"wires":[["48db04f7d334901b"]]},{"id":"48db04f7d334901b","type":"function","z":"7aa5b5b5.c7c5f8","name":"Take Picture","func":"msg.payload = {\n \"data\": \"http://192.168.50.60:8080/shot.jpg\"\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":60,"wires":[["d9daf7507bf38e9f"]]},{"id":"d9daf7507bf38e9f","type":"http request","z":"7aa5b5b5.c7c5f8","name":"Get Picture","method":"GET","ret":"bin","paytoqs":"ignore","url":"http://192.168.50.60:8080/photo.jpg","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"basic","senderr":false,"headers":[],"x":650,"y":60,"wires":[["9ca58ffd6eb64591"]]},{"id":"9ca58ffd6eb64591","type":"file","z":"7aa5b5b5.c7c5f8","name":"Save Picture","filename":"/media/Pictures/picture.jpg","filenameType":"str","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"none","x":830,"y":60,"wires":[[]]},{"id":"30307a46.24469a","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30,"areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 February 2023 21:02 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/2 "2023-02-12T21:02:32Z")

</div>

You could add a timestamp to the end of the name or create a numeric flow variable and add one to it each time you take a picture and add that to the name.

p.s. your flow was not importable. The three back-tic's have to be on a separate line. I edited it for you.

---

<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:** [12 February 2023 21:03 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/3 "2023-02-12T21:03:40Z")

</div>

You can use JSONata in the file write node path input. So you can append a datetime.  
e.g.

```auto
[{"id":"9ca58ffd6eb64591","type":"file","z":"da8a6ef0b3c9a5c8","name":"Save Picture","filename":"\"/media/Pictures/picture\" & $moment().format(\"YYYYMMDD_HHmmss\") & \".jpg\"","filenameType":"jsonata","appendNewline":false,"createDir":false,"overwriteFile":"false","encoding":"none","x":960,"y":4660,"wires":[[]]},{"id":"d9daf7507bf38e9f","type":"http request","z":"da8a6ef0b3c9a5c8","name":"Get Picture","method":"GET","ret":"bin","paytoqs":"ignore","url":"http://192.168.50.60:8080/photo.jpg","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"basic","senderr":false,"headers":[],"credentials":{"user":"","password":""},"x":780,"y":4660,"wires":[["9ca58ffd6eb64591"]]},{"id":"48db04f7d334901b","type":"function","z":"da8a6ef0b3c9a5c8","name":"Take Picture","func":"msg.payload = {\n \"data\": \"http://192.168.50.60:8080/shot.jpg\"\n};\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":4660,"wires":[["d9daf7507bf38e9f"]]},{"id":"ddcf9a5fdc523cf8","type":"switch","z":"da8a6ef0b3c9a5c8","name":"Value > 60?","property":"data.new_state.state","propertyType":"msg","rules":[{"t":"gt","v":"60","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":440,"y":4660,"wires":[["48db04f7d334901b"]]},{"id":"4416b46d00b74e1d","type":"server-state-changed","z":"da8a6ef0b3c9a5c8","name":"Motion Sensor","server":"30307a46.24469a","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.192_168_50_60_motion","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":"2","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":270,"y":4660,"wires":[["ddcf9a5fdc523cf8"]]}]

```

---

<div class="post-metadata">

**Author:** ![agassparkle](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@agassparkle](https://discourse.nodered.org/u/agassparkle)\
**Post date:** [12 February 2023 21:24 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/4 "2023-02-12T21:24:12Z")

</div>

Thank you very much. This worked very nice. wouldn't be able to figure out by my self.

I have an other issue.  
Can I write these pictures to a network drive ? Because i managed to mount a network drive and i can access to that drive from the media in the side bar. But when i write filesin /media/pictures it end up in local /media/pictures/.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 February 2023 21:25 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/5 "2023-02-12T21:25:14Z")

</div>

You will have to give it the full network path and you will have to have write access to that location

---

<div class="post-metadata">

**Author:** ![agassparkle](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@agassparkle](https://discourse.nodered.org/u/agassparkle)\
**Post date:** [12 February 2023 21:46 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/6 "2023-02-12T21:46:27Z")

</div>

You mean like this ?  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e63a902a17c391370bce187084a1239517f0a042.png)  
or something else ?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [12 February 2023 22:25 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/7 "2023-02-12T22:25:33Z")

</div>

That’s a url. When you say network device, do you mean a device on your local network or some device out in the cloud?

To use the file-out node, you need to give the path to the location. How the path is defined depends on the device and your OS.

---

<div class="post-metadata">

**Author:** ![agassparkle](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@agassparkle](https://discourse.nodered.org/u/agassparkle)\
**Post date:** [13 February 2023 12:03 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/8 "2023-02-13T12:03:22Z")

</div>

The setup is this,

Home assistant HAOS\_OVA-9.4 is running on an Ubuntu in KVM.  
All the drives are on Ubuntu shared with samba.  
Ubuntu ip is 192.168.50.51, Home assistant ip is 192.168.50.52.

I have also mounted this network drive using this  
` `  
`shell_command: mount_nas_folder: mkdir -p /media/Pictures;mount -t cifs -o vers=3.0,noserverino,username=agas,password=***,file_mode=0777,dir_mode=0777,domain=WORKGROUP //192.168.50.51/300/Pictures /media/Pictures`  
` `  
and adding the automation to run this on every restart. I can see the mounted folder from the media in the sidepanel. But i cannot write to it when use /media/Pictures/picture.jpg. These pictures end up in local /media/Pictures/. I am doing something terribly wrong but cant figure out what.

And thank you a lot for helping.

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [13 February 2023 12:17 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/9 "2023-02-13T12:17:50Z")

</div>

Since you're using Home Assistant, I suggest you ask on the node00red section of the Home Assistant forum. Not many people here (including me) use Home Assistant so you might get an answer there.

---

<div class="post-metadata">

**Author:** ![agassparkle](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@agassparkle](https://discourse.nodered.org/u/agassparkle)\
**Post date:** [15 February 2023 09:00 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/10 "2023-02-15T09:00:48Z")

</div>

Thank you

---

<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:** [16 April 2023 09:01 UTC](https://discourse.nodered.org/t/new-name-for-every-picture/75089/11 "2023-04-16T09:01:30Z")

</div>

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