Sub-directories can be created fairly easily with Node-Red. Here are a couple examples, I made these on a RIO so they are in the /secured folder.
[
{
"id": "f725ca04.50fb98",
"type": "file",
"z": "8975d3b4.47212",
"name": "",
"filename": "/home/dev/secured/subdir/filename.csv",
"appendNewline": true,
"createDir": true,
"overwriteFile": "true",
"encoding": "none",
"x": 450,
"y": 800,
"wires": [
[]
]
},
{
"id": "53a0d9e8.787398",
"type": "function",
"z": "8975d3b4.47212",
"name": "Write file name and contents",
"func": "var flowrate = 5;\nvar speed = 200;\nvar gain = -2;\nvar elapsed = 300;\nvar weight = 4500;\nmsg.payload=flowrate+\",\"+speed+\",\"+gain+\",\"+elapsed+\",\"+weight;\n\nvar home = \"home\";\nvar dev = \"dev\";\nvar secured = \"secured\";\nvar subdir2 = \"subdir2\";\nvar subsubdir2 = \"subsubdir2\";\n\nfile = \"/\"+ home + \"/\" + dev + \"/\" + secured + \"/\" + subdir2 + \"/\" + subsubdir2 + \".csv\";\nmsg.filename=file;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 360,
"y": 880,
"wires": [
[
"fe5fddea.eecde"
]
]
},
{
"id": "fe5fddea.eecde",
"type": "file",
"z": "8975d3b4.47212",
"name": "",
"filename": "",
"appendNewline": true,
"createDir": true,
"overwriteFile": "true",
"encoding": "none",
"x": 570,
"y": 880,
"wires": [
[]
]
},
{
"id": "71ebf833.35a8f8",
"type": "inject",
"z": "8975d3b4.47212",
"name": "",
"topic": "",
"payload": "",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 150,
"y": 880,
"wires": [
[
"53a0d9e8.787398"
]
]
},
{
"id": "2f8ffedc.e37e22",
"type": "inject",
"z": "8975d3b4.47212",
"name": "",
"topic": "",
"payload": "Hello opto world",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 180,
"y": 800,
"wires": [
[
"f725ca04.50fb98"
]
]
},
{
"id": "2b56f4da.d515dc",
"type": "comment",
"z": "8975d3b4.47212",
"name": "2 methods for creating subdirectories and files",
"info": "",
"x": 250,
"y": 740,
"wires": []
}
]