Parsing stdout output


I’m trying to build a workflow to backup my ESXi homelab snapshots. My first step is to list the folders using an execute command node: ssh -i ./id_rsa [email protected] "ssh -i ./id_rsa [email protected] “find /vmfs/volumes/datastore1/backup/ -maxdepth 1 | tail -n +2”

I’m getting the following result in the stdout
/vmfs/volumes/datastore1/backup/opnsense /vmfs/volumes/datastore1/backup/debian /vmfs/volumes/datastore1/backup/keeweb

those are the directories returned by the find command. my purpose is to parse those directories in order to iterate over them and execute a tar command using another node.

my question is: what is the best way to iterate over this stdout output?

You can use a Function-Node with the following code:

return items[0].json.stdout.split('\n').map(folder => {
  return {
    json: {

It will then add each of the folders as a different item. So all nodes after that will then automatically execute once for each of those items. So if you have another ExecuteCommand node afterward, will it execute once for each folder.

Hope that is helpful!