Hello this is my configuration :
i m on premise :
- n8n version: : 1.64.3
- Database (default: SQLite): Postgress
- n8n EXECUTIONS_PROCESS setting (default: own, main): : default
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system: : Debian 12
Problem Description:
I’m building a workflow that processes a list of CSV file records. I have a total of 5 items, one of which is a summary record (“fileName”: “Total”), which I later ignore.
The structure is as follows:
A Code node creates the 5 items
A Loop Over Items node processes them
A Replace Me node confirms that all 5 items go through
Then, in the Code1 Function node, I want to generate a new filename for each item
Issue:
Even though the Code1 node receives 5 items (I can confirm this in the input), it only outputs 1 item — it seems to process just the first one.
Workflow Screenshot:
Included in my post (see attached)
🔍 Debug & Observations:
Here’s what I currently have in Code1:
const data = $node["Code"];
const orga = data.json["Orga"];
const originalFilename = data.json["fileName"];
const newFilename = `_${orga}.csv`;
return {
json: {
originalFilename,
newFilename
}
};
Problem:
This accesses $node[“Code”].json, which only gives the first item — not all the items passed from the previous node.
What I Want:
I want the node to rename each file individually, and return 4 renamed files (excluding the “Total” item).
Use $json instead of $node[...] inside a Function node when you’re processing multiple items (especially after a Loop):
const dateExploitation = ""; // or use $node["foundDateExploitation"].json["dateOnly"];
const orga = $json["Orga"];
const originalFilename = $json["fileName"];
const newFilename = `${dateExploitation}_${orga}.csv`;
return {
json: {
originalFilename,
newFilename
}
};
Expected Output:
[
{ "originalFilename": "file-A.csv", "newFilename": "2025-05-16_1.csv" },
{ "originalFilename": "file-B.csv", "newFilename": "2025-05-16_2.csv" },
...
]
Attached:
Sample input data