File Operations Node

Absolute newbie to Automate / Node Red. I am trying to create a simple folder capture - send to folder Flow, with a dynamic output filename.

I have figured out that I need a Change or Function Node in-between to dynamically set the output destination and filename. I need some basic guidance into best practices. If I want to append a timestamp to the output filename, for example?

Currently I’m doing a “Change” to search for the “Input” foldername in the path and changing it to “Output” but I’m going to need much more robust alterations to paths and filenames. I’m looking for best practices to avoid teaching myself bad habits as I learn this!

[
{
“id”: “7615da8e6333db8f”,
“type”: “tab”,
“label”: “Flow 1”,
“disabled”: false,
“info”: “”,
“env”:
},
{
“id”: “7b35f5d7165612f7”,
“type”: “olfnf-folder-capture-in”,
“z”: “7615da8e6333db8f”,
“folder”: “E:\pbCCMData\GUILD\Node_Red\Input”,
“folder_type”: “str”,
“create_directory”: true,
“subfolder”: false,
“ignoreempty”: true,
“masks”: “.”,
“masksregex”: false,
“watchMethod”: “polling”,
“name”: “”,
“x”: 210,
“y”: 100,
“wires”: [
[
“92acee509326f4aa”
]
]
},
{
“id”: “92acee509326f4aa”,
“type”: “change”,
“z”: “7615da8e6333db8f”,
“name”: “”,
“rules”: [
{
“t”: “change”,
“p”: “payload”,
“pt”: “msg”,
“from”: “Input”,
“fromt”: “str”,
“to”: “Output”,
“tot”: “str”
}
],
“action”: “”,
“property”: “”,
“from”: “”,
“to”: “”,
“reg”: false,
“x”: 420,
“y”: 100,
“wires”: [
[
“d15a6fe619ace7aa”
]
]
},
{
“id”: “d15a6fe619ace7aa”,
“type”: “olfnf-file-operations”,
“z”: “7615da8e6333db8f”,
“operation”: “move”,
“source_file”: “filename”,
“source_file_type”: “msg”,
“target_file”: “payload”,
“target_file_type”: “msg”,
“create_directory”: true,
“name”: “”,
“x”: 640,
“y”: 100,
“wires”: [

]
}
]

The folder capture node outputs the path to the input file in msg.payload (also msg.filename) and various other file properties in msg.file, such as the basename, name, file extension, and folder location.

This information can be utilized in Change nodes, Functions, and for operations like J expressions (JSONata).

The following image shows this information in the Debug panel.

Adding a timestamp can be done in a Function or using J expression as discussed in your other topic :wink: (Output Presets and filenames - #3 by TGREER)

Erik

Hi Erik, How does it work with a folder capture as in worflow the file would have dissapeared from the folder once it was picked up and held in memory. If the file disspears then using the msg.filename wouldn’t work as it’s not there anymore.

I@m using a input module at the moment as I’m running in debug but gettign a problem with file operations node as it’s saying the target path can’t be accessed even though I know it’s right as I’ve used the same expression on a folder options to create teh folder before to make sure it wasn’t a permission issues

Permissions error: unable to access target path: /mnt/upg01/Apps/LE02010/JobBags/Z100000018663/Original/samplefile.txt

It has already been some time ago since, but can you please share a screenshot of the flow? Because I am not entirely sure what you mean by “input module”.