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.
[
{
"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"
]
]
}
]