Boring update day so... just for future reference 
[{"id":"8651173a2beba2a6","type":"function","z":"d205ec506260c61e","name":"read file","func":"fs.readFile(msg.files.path, 'utf8', (err, data) => {\n if (err) {\n //node.warn(err);\n node.status({fill:\"red\",shape:\"dot\",text:\"Error reading file: \" + msg.files.path});\n return\n } \n msg.payload = data;\n node.send(msg);\n node.status({fill:\"green\",shape:\"dot\",text:\"Done\"});\n node.done();\n\n});\nreturn\n\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"fs","module":"fs"}],"x":860,"y":640,"wires":[["0329db9f676a6193"]]},{"id":"4875781a96d4bca9","type":"function","z":"d205ec506260c61e","name":"read dir","func":"fs.readdir(msg.path,{withFileTypes: true}, function (err, files) {\n //handling error\n if (err) {\n //node.warn('Unable to scan directory: ' + err);\n node.status({fill:\"red\",shape:\"ring\",text:'Unable to scan directory: ' + err});\n return;\n } \n msg.files = files.filter((dirent) => dirent.isFile());\n node.send(msg);\n node.status({fill:\"green\",shape:\"dot\",text:\"Done\"});\n node.done();\n});\nreturn\n\n\n\n\n","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"fs","module":"fs"},{"var":"path","module":"path"}],"x":400,"y":620,"wires":[["513a08f4be7f06eb","dfdc981a700d8042"]]},{"id":"b8a6979723d2ddc3","type":"inject","z":"d205ec506260c61e","name":"path","props":[{"p":"path","v":"/home/USER/test/","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":620,"wires":[["4875781a96d4bca9"]]},{"id":"ebe1a7751aeedbd9","type":"split","z":"d205ec506260c61e","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","property":"files","x":690,"y":640,"wires":[["8651173a2beba2a6"]]},{"id":"ac9bf89eaeb65c23","type":"function","z":"d205ec506260c61e","name":"mv","func":"\nfor (let index = 0; index < msg.files.length; index++) {\n\n const name = msg.files[index].name\n const parentPath = msg.files[index].parentPath\n const sourceFile = msg.files[index].path\n const targetDir = path.join(parentPath, \"archive\");\n const targetFile = path.join(targetDir, name);\n\n fs.mkdir(targetDir, { recursive: true }, (err) => {\n if (err) node.warn(err);\n return;\n });\n\n\n fs.rename(sourceFile, targetFile, (err) => {\n if (err) {\n node.status({fill:\"red\",shape:\"dot\",text:\"Error moving files: \" + err});\n } else {\n node.status({fill:\"green\",shape:\"dot\",text:\"Done\"});\n } \n });\n\n node.done\n \n}\nreturn","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[{"var":"fs","module":"fs"},{"var":"path","module":"path"}],"x":690,"y":580,"wires":[[]]},{"id":"0329db9f676a6193","type":"debug","z":"d205ec506260c61e","name":"debug 8","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1020,"y":640,"wires":[]},{"id":"dfdc981a700d8042","type":"debug","z":"d205ec506260c61e","name":"debug 9","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":620,"y":720,"wires":[]},{"id":"af8012b919ce775c","type":"comment","z":"d205ec506260c61e","name":"set path here!","info":"","x":210,"y":580,"wires":[]},{"id":"513a08f4be7f06eb","type":"junction","z":"d205ec506260c61e","x":540,"y":620,"wires":[["ebe1a7751aeedbd9"]]}]