Persist root google drive information in child file items

I am outputting a list of corporate google shared drives in node 1, then listing all of the files and folders for each of these output drives in node 2. I would like to somehow carry forward and include the “parent” root drive from node 1 in each output item of node 2.

I have the vague sense that I can accomplish this with a merge node or a set somehow, but there isn’t anything to match on.

For example, if I have “root folder 1” with “child item 1” and “child item 2” in it and “root folder 2” with “child item 3” and “child item 4” in it, I want a final output that looks like this:

[
  {
  "root": "root folder 1",
  "name": "child item 1"
  },
  {
  "root": "root folder 1",
  "name": "child item 2"
  },
  {
  "root": "root folder 2",
  "name": "child item 3"
  },
  {
  "root": "root folder 2",
  "name": "child item 4"
  }
]

Can anyone offer advice?

1 Like

Hello @jonm!
Welcome to the community!

I suppose you can fix that with a Set node + Looping logic.

  1. In your first node, listing shared drives

  2. Use a Split Out node
    Split the shared drives into individual items if not already split.

  3. Inside the loop for each drive: set the current shared drive name or ID as a field, e.g. driveName

Then pass that into the node that lists the files for that drive. This way, every time you call the “list files” node, you’re passing in a custom field like:

{ “root”: “Shared Drive A” }

  1. After listing the files:
    Use a Function node to attach the root value from the parent item to each file.
    This will copy the root value into each of the file items.

Let me know!
Cheers

1 Like

Thank you for your response! Unfortunately, I’m not sure I follow. After listing drives, I have output that looks like this:

  {
    "kind": "drive#drive",
    "id": "asdfasdf-asdfa3413",
    "name": "Root Drive 1"
  },
  {
    "kind": "drive#drive",
    "id": "asdfasdf-asfasasdf",
    "name": "Root Drive 2"
  }

This becomes the input for the next node, which automatically loops through the ids and outputs a combined list of all the from both of those drives. There is nothing at all to relate the individual items in this output back to their original root drive name or id. That output looks like this:

[
  {
    "kind": "drive#file",
    "id": "asdf_asdf1",
    "name": "file 1 which happens to be from Root Drive 1 but we dont know that"
  },
  {
    "kind": "drive#file",
    "id": "asdf_asdf2",
    "name": "file 2 which happens to be from Root Drive 1 but we dont know that"
  },
  {
    "kind": "drive#file",
    "id": "asdf_asdf3",
    "name": "file 3 which appens to be from Root Drive 2 but we dont know that"
  }
]

I don’t see how splitting out information I already have in the input helps me reconstruct where each file in the output came from in a function afterwards.

Thank you for your help so far. Please help me understand.

Hi I think I can help.

I dont have a Google workspace account so I cant test it myself. But if you do shared drive, then operation get. I think you should get the files in that folder.

Which would mean the workflow below would work.

Thanks, but that’s just example data. In actuality, I’m dealing with many drives and thousands of files. The node output doesn’t include which files belong to which drives once they are listed or the counts. I’ve tried splitting it up into a loop node with a merge node, but I can’t find a way to join the original drive name to the output items.

I see, but doesn’t it show files for one folder with the GET folder instead of GET folders? I can only go with past experiences, but most of the time getting one folder usually gives the content details.

I figured it out! It looks like this.

1 Like