# Is there any way to check msg.payload is a file or folder?

**URL:** https://discourse.nodered.org/t/is-there-any-way-to-check-msg-payload-is-a-file-or-folder/33329
**Category:** General
**Created:** [25 September 2020 07:27 UTC](https://discourse.nodered.org/t/is-there-any-way-to-check-msg-payload-is-a-file-or-folder/33329 "2020-09-25T07:27:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)
#### Post date: [25 September 2020 07:27 UTC](https://discourse.nodered.org/t/is-there-any-way-to-check-msg-payload-is-a-file-or-folder/33329/1 "2020-09-25T07:27:41Z")

</div>

I would like to check if `msg.payload` is **a file** or **a directory** without using the `function` node,  
is there a node that can check this?  
Please tell me!  
Thanks.

---

<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: [25 September 2020 09:22 UTC](https://discourse.nodered.org/t/is-there-any-way-to-check-msg-payload-is-a-file-or-folder/33329/2 "2020-09-25T09:22:09Z")

</div>

You really haven’t given enough information for anyone to help you.  
Where is msg.payload coming from?  
What else is in the msg object?

---

<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: [25 September 2020 10:03 UTC](https://discourse.nodered.org/t/is-there-any-way-to-check-msg-payload-is-a-file-or-folder/33329/3 "2020-09-25T10:03:28Z")

</div>

> [@minhhn0205](#):
>
> I would like to check if `msg.payload` is **a file** or **a directory**

I can only assume (due to lack of information / screen shots) that you mean "I would like to check if the string value contained in `msg.payload` is **a file** or **a directory**" - is that what you mean?

If so, you can use fs-ops

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/73c5fb9cec956ecfe79785403c6d53236c615d35.png)

```auto
[{"id":"2d2407c0.e47ad8","type":"inject","z":"d1c281e9.1a622","name":"myfolder","topic":"myfolder","payload":"myfolder","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1520,"y":80,"wires":[["7a0a4cf0.988b14"]]},{"id":"3e55bccd.fbf104","type":"inject","z":"d1c281e9.1a622","name":"img.png","topic":"img.png","payload":"img.png","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1510,"y":120,"wires":[["7a0a4cf0.988b14"]]},{"id":"7a7799a0.09e508","type":"debug","z":"d1c281e9.1a622","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1690,"y":120,"wires":[]},{"id":"7a0a4cf0.988b14","type":"fs-ops-type","z":"d1c281e9.1a622","name":"","path":"c:\\temp","pathType":"str","filename":"payload","filenameType":"msg","filetype":"type","filetypeType":"msg","x":1680,"y":80,"wires":[["7a7799a0.09e508"]]}]

```

---

<div class="post-metadata">

### Author: ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)
#### Post date: [25 September 2020 12:05 UTC](https://discourse.nodered.org/t/is-there-any-way-to-check-msg-payload-is-a-file-or-folder/33329/4 "2020-09-25T12:05:10Z")

</div>

@Steve-Mcl Amazing, exactly what I wanted to do, 1000 likes 😊  
Thank everyone for the support!

---

<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 October 2020 12:05 UTC](https://discourse.nodered.org/t/is-there-any-way-to-check-msg-payload-is-a-file-or-folder/33329/5 "2020-10-09T12:05:16Z")

</div>

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