# Test if the file exist

**URL:** <https://discourse.nodered.org/t/test-if-the-file-exist/14271>\
**Category:** General\
**Created:** [13 August 2019 09:20 UTC](https://discourse.nodered.org/t/test-if-the-file-exist/14271 "2019-08-13T09:20:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oli.nodered](https://avatars.discourse-cdn.com/v4/letter/o/e9bcb4/32.png) [@oli.nodered](https://discourse.nodered.org/u/oli.nodered)\
**Post date:** [13 August 2019 09:20 UTC](https://discourse.nodered.org/t/test-if-the-file-exist/14271/1 "2019-08-13T09:20:23Z")

</div>

Bonjour

i want to know if a file exist on my application.  
For my test i use fs-ops-access and it is ok if the parameter Filename is unchangeable.  
But for my application i want to change dynamically the Filename property.  
Can you help me ?

my node

[  
{  
"id": "df863d4.60fed4",  
"type": "tab",  
"label": "Flow 7",  
"disabled": false,  
"info": ""  
},  
{  
"id": "27170ae.b550176",  
"type": "fs-ops-access",  
"z": "df863d4.60fed4",  
"name": "",  
"path": "Documents/Datas",  
"pathType": "str",  
"filename": "filecsv.cs",  
"filenameType": "str",  
"read": true,  
"write": true,  
"throwerror": true,  
"x": 700,  
"y": 420,  
"wires": [  
[  
"39b43f98.6b1c8"  
],  
[  
"3c84cbdc.0cf004"  
]  
]  
},  
{  
"id": "ff561338.be1528",  
"type": "inject",  
"z": "df863d4.60fed4",  
"name": "",  
"topic": "",  
"payload": "",  
"payloadType": "date",  
"repeat": "",  
"crontab": "",  
"once": false,  
"onceDelay": 0.1,  
"x": 320,  
"y": 420,  
"wires": [  
[  
"a18cc6af.01003"  
]  
]  
},  
{  
"id": "39b43f98.6b1c8",  
"type": "debug",  
"z": "df863d4.60fed4",  
"name": "",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "true",  
"targetType": "full",  
"x": 880,  
"y": 380,  
"wires":   
},  
{  
"id": "3c84cbdc.0cf004",  
"type": "debug",  
"z": "df863d4.60fed4",  
"name": "",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "true",  
"targetType": "full",  
"x": 870,  
"y": 460,  
"wires":   
},  
{  
"id": "a18cc6af.01003",  
"type": "function",  
"z": "df863d4.60fed4",  
"name": "",  
"func": "msg={Filename :"filecsv.csv"};\nreturn msg;",  
"outputs": 1,  
"noerr": 0,  
"x": 490,  
"y": 420,  
"wires": [  
[  
"27170ae.b550176",  
"cc12c5d4.1ccb08"  
]  
]  
},  
{  
"id": "cc12c5d4.1ccb08",  
"type": "debug",  
"z": "df863d4.60fed4",  
"name": "",  
"active": true,  
"tosidebar": true,  
"console": false,  
"tostatus": false,  
"complete": "true",  
"targetType": "full",  
"x": 700,  
"y": 600,  
"wires":   
}  
]

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [13 August 2019 09:25 UTC](https://discourse.nodered.org/t/test-if-the-file-exist/14271/2 "2019-08-13T09:25:50Z")

</div>

Unfortunately your flow isn't currently importable.Please read the following post [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506) and then edit the above message.

Also what is the full name of the node you are using as "fs-ops-access" doesn't return any hits on [flows.nodered.org](http://flows.nodered.org)

---

<div class="post-metadata">

**Author:** ![oli.nodered](https://avatars.discourse-cdn.com/v4/letter/o/e9bcb4/32.png) [@oli.nodered](https://discourse.nodered.org/u/oli.nodered)\
**Post date:** [13 August 2019 09:32 UTC](https://discourse.nodered.org/t/test-if-the-file-exist/14271/3 "2019-08-13T09:32:36Z")

</div>

```auto
[{"id":"df863d4.60fed4","type":"tab","label":"Flow 7","disabled":false,"info":""},{"id":"27170ae.b550176","type":"fs-ops-access","z":"df863d4.60fed4","name":"","path":"Documents/Datas","pathType":"str","filename":"filecsv.cs","filenameType":"str","read":true,"write":true,"throwerror":true,"x":700,"y":420,"wires":[["39b43f98.6b1c8"],["3c84cbdc.0cf004"]]},{"id":"ff561338.be1528","type":"inject","z":"df863d4.60fed4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":320,"y":420,"wires":[["a18cc6af.01003"]]},{"id":"39b43f98.6b1c8","type":"debug","z":"df863d4.60fed4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":880,"y":380,"wires":[]},{"id":"3c84cbdc.0cf004","type":"debug","z":"df863d4.60fed4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":460,"wires":[]},{"id":"a18cc6af.01003","type":"function","z":"df863d4.60fed4","name":"","func":"msg={Filename :\"filecsv.csv\"};\nreturn msg;","outputs":1,"noerr":0,"x":490,"y":420,"wires":[["27170ae.b550176","cc12c5d4.1ccb08"]]},{"id":"cc12c5d4.1ccb08","type":"debug","z":"df863d4.60fed4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":700,"y":600,"wires":[]}]

```

---

<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:** [13 August 2019 09:45 UTC](https://discourse.nodered.org/t/test-if-the-file-exist/14271/4 "2019-08-13T09:45:23Z")

</div>

> [@ukmoose](#):
>
> Also what is the full name of the node you are using as "fs-ops-access" doesn't return any hits on

Pretty sure its this one...

> **[node-red-contrib-fs-ops](https://flows.nodered.org/node/node-red-contrib-fs-ops)**
>
> A node-red node to perform basic file system operations.

@oli.nodered

You are trying to pass filename via `msg.Filename` but you have entered a fixed filename in the config...

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

This should be ...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/f/f67d09fce60c95216d534c51db5d9ac38dd53a66.png)

to match up with your function...

```auto
msg={Filename :"filecsv.csv"};
return msg;

```

One suggestion - leave the msg object as it is & just set a property (helps further down the flow to see what the original msg was. E.g. use this in your function code...

```auto
msg.Filename = "filecsv.csv";
return msg;

```

Better still, use a change node...  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/5/5b6682784b9fe6b17e62b64a4c1737ed2020811c.png)

---

<div class="post-metadata">

**Author:** ![oli.nodered](https://avatars.discourse-cdn.com/v4/letter/o/e9bcb4/32.png) [@oli.nodered](https://discourse.nodered.org/u/oli.nodered)\
**Post date:** [13 August 2019 10:37 UTC](https://discourse.nodered.org/t/test-if-the-file-exist/14271/5 "2019-08-13T10:37:23Z")

</div>

Just merci  
it is ok. that help for my futur application

Merci  
Olivier
