Unable to get the file size of multiple files using Advanced FTP node

I am getting file size for single filename from my remote FTP using Advanced FTP node which is working fine.
But Now I wanted to get the file size of 7 files which needs to send to FTP node one by one and save it in an array and then show as a result of filenames and their size. I tried many logics but didn't work.
It is not feasible to get the list of directory every time and compare it with the require files available in my local directory.
I would be grateful if someone can suggest me a solution.

I suggest fs-ops to the rescue.

Demo Flow (use CTRL+I to import)

[
    {
        "id": "44568381f16b99bc",
        "type": "inject",
        "z": "6429d72ae185e590",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 1210,
        "y": 100,
        "wires": [
            [
                "a742fc1c40ebb3fb"
            ]
        ]
    },
    {
        "id": "87800c16b499cd24",
        "type": "function",
        "z": "6429d72ae185e590",
        "name": "Summary of files",
        "func": "\n/** @type {[Number]} */\nconst stats = msg.stats\n\nconst byteSize = stats.reduce(function (a, b) {\n    return a + b.size\n}, 0);\n\n\nmsg.payload = {\n    files: msg.files,\n    stats: msg.stats,\n    totalBytes: byteSize,\n    totalKBs: (byteSize / 1000).toFixed(3)\n}\n\n\nreturn msg;\n",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 1320,
        "y": 160,
        "wires": [
            [
                "1f7871d95c546042"
            ]
        ]
    },
    {
        "id": "a742fc1c40ebb3fb",
        "type": "fs-ops-dir",
        "z": "6429d72ae185e590",
        "name": "",
        "path": "c:/temp",
        "pathType": "str",
        "filter": "*.zip",
        "filterType": "str",
        "dir": "files",
        "dirType": "msg",
        "x": 1360,
        "y": 100,
        "wires": [
            [
                "21f451c9ccd00507"
            ]
        ]
    },
    {
        "id": "21f451c9ccd00507",
        "type": "fs-ops-stats",
        "z": "6429d72ae185e590",
        "name": "",
        "path": "c:/temp",
        "pathType": "str",
        "filename": "files",
        "filenameType": "msg",
        "stats": "stats",
        "sizeType": "msg",
        "x": 1510,
        "y": 100,
        "wires": [
            [
                "87800c16b499cd24"
            ]
        ]
    },
    {
        "id": "1f7871d95c546042",
        "type": "debug",
        "z": "6429d72ae185e590",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1510,
        "y": 160,
        "wires": []
    }
]
2 Likes

Thanks!
However using fs-ops I can access only the local files only. I want to get the size of the files from my remote server which can only possible by FTP nodes.
But now I have figured out another solution and is working fine.
One again thank you so much!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.