# Extracting and manipulating data with node exec

**URL:** https://discourse.nodered.org/t/extracting-and-manipulating-data-with-node-exec/74789
**Category:** General
**Tags:** function-node, exec
**Created:** [6 February 2023 14:29 UTC](https://discourse.nodered.org/t/extracting-and-manipulating-data-with-node-exec/74789 "2023-02-06T14:29:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![felipeneves](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@felipeneves](https://discourse.nodered.org/u/felipeneves)
#### Post date: [6 February 2023 14:29 UTC](https://discourse.nodered.org/t/extracting-and-manipulating-data-with-node-exec/74789/1 "2023-02-06T14:29:17Z")

</div>

Hello everyone, everything good?  
I'm not a programmer, I'm from the computer network area, I have a problem with a flow, I'll try to explain what it does, I want it to read the files from inside the folder c:\fotos\3, after reading the files , it plays one by one for "http://"+192.168.200.13:1880/3/+filename/" if there is only one file inside the folder, it works, but if there are more than 1, it plays all files in one link, can you help me with this? Thank you very much!!!! below I will post my flow

```auto
[
    {
        "id": "6729132ba69e35f1",
        "type": "tab",
        "label": "Flow 20",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "254844678aac9bd3",
        "type": "exec",
        "z": "6729132ba69e35f1",
        "command": "dir",
        "addpay": "filename",
        "append": "",
        "useSpawn": "false",
        "timer": "5",
        "winHide": false,
        "oldrc": false,
        "name": "Exec",
        "x": 730,
        "y": 360,
        "wires": [
            [
                "d5f92713a738f11d"
            ],
            [],
            []
        ]
    },
    {
        "id": "a7c10d94fb83f8cf",
        "type": "function",
        "z": "6729132ba69e35f1",
        "name": "function 12",
        "func": "var ipservidor = \"192.168.200.13\";\nvar id = msg.payload.id;\n\n\nmsg.filename = \"c:\\\\fotos\\\\\"+id+\"\\\\\"+\"/b\";\nmsg.url = \"http://\"+ipservidor+\":1880/\"+id+\"/\";\n\n\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 530,
        "y": 360,
        "wires": [
            [
                "254844678aac9bd3"
            ]
        ]
    },
    {
        "id": "d5f92713a738f11d",
        "type": "function",
        "z": "6729132ba69e35f1",
        "name": "",
        "func": "var urlfotos = msg.url;\nvar nomesarquivos = msg.payload;\n\n\nvar urlcompleta = msg.url+msg.payload;\n\n\nmsg.urlcompleta = urlcompleta;\n\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 920,
        "y": 360,
        "wires": [
            [
                "00fe6360698f84d8"
            ]
        ]
    },
    {
        "id": "00fe6360698f84d8",
        "type": "debug",
        "z": "6729132ba69e35f1",
        "name": "debug 26",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1100,
        "y": 360,
        "wires": []
    },
    {
        "id": "1dbb92b370aff561",
        "type": "inject",
        "z": "6729132ba69e35f1",
        "name": "",
        "props": [
            {
                "p": "payload.id",
                "v": "3",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 330,
        "y": 360,
        "wires": [
            [
                "a7c10d94fb83f8cf"
            ]
        ]
    }
]
```

---

<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: [6 February 2023 15:53 UTC](https://discourse.nodered.org/t/extracting-and-manipulating-data-with-node-exec/74789/2 "2023-02-06T15:53:28Z")

</div>

> I want it to read the files from inside the folder c:\fotos\3

Where are you reading the files? Are the files on the device running NR? if so you could use one of the `file` nodes.

Put a debug node on the output of your `function` node and show what it returns.

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

---

<div class="post-metadata">

### Author: ![felipeneves](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@felipeneves](https://discourse.nodered.org/u/felipeneves)
#### Post date: [6 February 2023 16:01 UTC](https://discourse.nodered.org/t/extracting-and-manipulating-data-with-node-exec/74789/3 "2023-02-06T16:01:21Z")

</div>

Thanks for the answer.  
Hello friend, yes I use the debugs in the outputs, as it is in my flow, below I will send an image of the return. I'm using exec-node to read the files.

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

---

<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: [6 February 2023 16:09 UTC](https://discourse.nodered.org/t/extracting-and-manipulating-data-with-node-exec/74789/4 "2023-02-06T16:09:55Z")

</div>

1. Could you answer ALL the questions I asked.
2. please set the debug node to display the complete msg object and attach it to the output of the exec node.

---

<div class="post-metadata">

### Author: ![felipeneves](https://avatars.discourse-cdn.com/v4/letter/f/ccd318/32.png) [@felipeneves](https://discourse.nodered.org/u/felipeneves)
#### Post date: [6 February 2023 16:34 UTC](https://discourse.nodered.org/t/extracting-and-manipulating-data-with-node-exec/74789/5 "2023-02-06T16:34:42Z")

</div>

Alright I'm answering now.

1: I'm reading the files from the directory "c:\fotos\3" in the WINDOWS operating system, where node-red is running.

2: Are the files on the device running NR? --- This one I don't understand.

The debug already had a complete msg, but it was in the output of the function, I put it in the exec node, below I send the image.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/98c2d361db9c230bfc4ef3a17bd1a747e355881f.png)

---

<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: [7 April 2023 16:35 UTC](https://discourse.nodered.org/t/extracting-and-manipulating-data-with-node-exec/74789/6 "2023-04-07T16:35:20Z")

</div>

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