How to Search 5 Random Files from Google Drive and Get Shareable Links in Make.com?

How to Search 5 Random Files from Google Drive and Get Shareable Links in Make.com?

Hi everyone,

I have a Google Drive folder with more than 2500 files, all named sequentially from LeaMarie1.png to LeaMarie2500.png. I want to create an automation in Make.com that:

  1. Selects 5 random files from this folder.
  2. Retrieves their file IDs.
  3. Generates shareable links for them.

I tried using the following query to generate a random filename:

make

CopyEdit

{{add(emptyarray; "LeaMarie"; floor(random * 2500) + 1 ;"LeaMarie"; )}}

However, this only returns one image at a time, but I need five in a single execution.

What’s the best way to generate 5 random file names at once and use them in the automation? Any help or alternative approach would be greatly appreciated!

Thanks in advance! :blush:

Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of four modules:

This is just an example. Your final solution may or may not look like this depending on your requirements.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Module Export - quick import into your scenario

You can copy and paste this module export into your scenario. This will import the modules (with fields/settings/filters) shown in my screenshots above.

  1. Move your mouse over the line of code below. Copy the JSON by clicking the copy button on the right of the code, which looks like this:

  2. Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the editor.

  3. Click on each imported module and re-save it for validation. There may be some errors prompting you to remap some variables and connections.

JSON module export — paste this directly in your scenario

{"subflows":[{"flow":[{"id":276,"module":"google-drive:searchForFilesFolders","version":4,"parameters":{"__IMTCONN__":94797},"mapper":{"select":"list","retrieve":"file","limit":"99999","destination":"drive","folderId":"/"},"metadata":{"designer":{"x":410,"y":-2049},"parameters":[{"name":"__IMTCONN__","type":"account:google-restricted","label":"Connection","required":true}]}},{"id":277,"module":"builtin:BasicAggregator","version":1,"parameters":{"feeder":276},"filter":{"name":"permission","conditions":[[{"a":"{{276.ownedByMe}}","o":"boolean:equal","b":"{{true}}"},{"a":"{{276.owners[].me}}","o":"boolean:equal","b":"{{true}}"},{"a":"{{276.mimeType}}","o":"text:notcontain:ci","b":"folder"}]]},"mapper":{"id":"{{276.id}}"},"metadata":{"designer":{"x":701,"y":-2049}}},{"id":278,"module":"builtin:BasicFeeder","version":1,"parameters":{},"mapper":{"array":"{{slice(shuffle(map(277.array; \"id\")); 0; 5)}}"},"metadata":{"designer":{"x":942,"y":-2051}}},{"id":279,"module":"google-drive:shareAFileFolder","version":4,"parameters":{"__IMTCONN__":94797},"mapper":{"destination":"drive","select":"file","role":"reader","type":"anyone","file":"{{278.value}}","allowFileDiscovery":false},"metadata":{"designer":{"x":1187,"y":-2054},"parameters":[{"name":"__IMTCONN__","type":"account:google-restricted","label":"Connection","required":true}]}}]}],"metadata":{"version":1}}

Note: Did you know you can reduce the size of blueprints and module export code like the above, using the Make Blueprint Scrubber?

3 Likes

Its working , Thank you so much :pray:t2:

No problem, glad I could help!

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.