# Not able to move a file

**URL:** <https://discourse.nodered.org/t/not-able-to-move-a-file/62388>\
**Category:** General\
**Created:** [9 May 2022 08:28 UTC](https://discourse.nodered.org/t/not-able-to-move-a-file/62388 "2022-05-09T08:28:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![milner236](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@milner236](https://discourse.nodered.org/u/milner236)\
**Post date:** [9 May 2022 08:28 UTC](https://discourse.nodered.org/t/not-able-to-move-a-file/62388/1 "2022-05-09T08:28:33Z")

</div>

Hello everyone,  
I am struggling to move a file using node-red-contrib-fs-ops.  
I always find myself at the point where the file is undefined.  
What am I doing wrong?  
Path and Destination are set in the function node.

```auto
[
    {
        "id": "657bc454440ed88a",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "8613b7691622cada",
        "type": "inject",
        "z": "657bc454440ed88a",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 240,
        "wires": [
            [
                "4a6d9a9526120dde"
            ]
        ]
    },
    {
        "id": "b4ee680342af45e5",
        "type": "debug",
        "z": "657bc454440ed88a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 470,
        "y": 400,
        "wires": []
    },
    {
        "id": "5069402c4399f2e9",
        "type": "file",
        "z": "657bc454440ed88a",
        "name": "",
        "filename": "",
        "appendNewline": true,
        "createDir": false,
        "overwriteFile": "false",
        "encoding": "none",
        "x": 920,
        "y": 120,
        "wires": [
            [
                "9e9a73056c7fffa4"
            ]
        ]
    },
    {
        "id": "bf608ece087533ca",
        "type": "template",
        "z": "657bc454440ed88a",
        "name": "",
        "field": "newfile",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "{{filename}}.txt",
        "output": "str",
        "x": 760,
        "y": 120,
        "wires": [
            [
                "5069402c4399f2e9"
            ]
        ]
    },
    {
        "id": "7f613ecb26037f58",
        "type": "file in",
        "z": "657bc454440ed88a",
        "name": "",
        "filename": "",
        "format": "",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 620,
        "y": 220,
        "wires": [
            [
                "c274491b09e193d0",
                "6a182c9849c48b8b"
            ]
        ]
    },
    {
        "id": "9e9a73056c7fffa4",
        "type": "delay",
        "z": "657bc454440ed88a",
        "name": "",
        "pauseType": "delay",
        "timeout": "5",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 1080,
        "y": 120,
        "wires": [
            [
                "7f613ecb26037f58"
            ]
        ]
    },
    {
        "id": "6b514a523c872df2",
        "type": "debug",
        "z": "657bc454440ed88a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": true,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1100,
        "y": 260,
        "wires": []
    },
    {
        "id": "4a6d9a9526120dde",
        "type": "file in",
        "z": "657bc454440ed88a",
        "name": "",
        "filename": "randomfile.pdf",
        "format": "",
        "chunk": false,
        "sendError": false,
        "encoding": "none",
        "allProps": false,
        "x": 220,
        "y": 280,
        "wires": [
            [
                "b4ee680342af45e5",
                "fbbd7de4c51603f0"
            ]
        ]
    },
    {
        "id": "50237e0a7b1147ed",
        "type": "function",
        "z": "657bc454440ed88a",
        "name": "get paragraph",
        "func": "const regex = /המדד של חודש.*?\\./gms;\nlet m;\n\nwhile ((m = regex.exec(msg.payload)) !== null) {\n // This is necessary to avoid infinite loops with zero-width matches\n if (m.index === regex.lastIndex) {\n regex.lastIndex++;\n }\n\n // The result can be accessed through the `m`-variable.\n m.forEach((match, groupIndex) => {\n node.send({payload: match});\n });\n}\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1000,
        "y": 200,
        "wires": [
            [
                "6b514a523c872df2"
            ]
        ]
    },
    {
        "id": "c274491b09e193d0",
        "type": "debug",
        "z": "657bc454440ed88a",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 870,
        "y": 260,
        "wires": []
    },
    {
        "id": "6a182c9849c48b8b",
        "type": "fs-ops-move",
        "z": "657bc454440ed88a",
        "name": "",
        "sourcePath": "source1",
        "sourcePathType": "msg",
        "sourceFilename": "file",
        "sourceFilenameType": "msg",
        "destPath": "destination1",
        "destPathType": "msg",
        "destFilename": "file",
        "destFilenameType": "msg",
        "link": false,
        "x": 820,
        "y": 200,
        "wires": [
            [
                "50237e0a7b1147ed"
            ]
        ]
    },
    {
        "id": "fbbd7de4c51603f0",
        "type": "function",
        "z": "657bc454440ed88a",
        "name": "",
        "func": "//msg.file = msg.filename;// save file name before overwriting (just in case)\nmsg.source1 = \"path2\" ;\nmsg.destination1 = \"path1\" ;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 580,
        "y": 160,
        "wires": [
            [
                "bf608ece087533ca"
            ]
        ]
    }
]

```

---

<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:** [9 May 2022 08:52 UTC](https://discourse.nodered.org/t/not-able-to-move-a-file/62388/2 "2022-05-09T08:52:32Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/9/89e9cecb96399da16b4c0d6cbb3f82526094bc27.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:** [8 July 2022 08:53 UTC](https://discourse.nodered.org/t/not-able-to-move-a-file/62388/3 "2022-07-08T08:53:07Z")

</div>

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