• Instructions to Ask a Question

    For any assistance, please click the "Ask a Question" button and select the Pabbly product for which you require support.

    We offer seven comprehensive applications designed to help you efficiently manage and grow your business:

    Our support team endeavors to respond within 24 business hours (Monday to Friday, 10:00 AM to 6:00 PM IST). We appreciate your understanding and patience.

    🚀 Exclusive Lifetime Offers 🚀

    We invite you to take advantage of our special one-time payment plans, providing lifetime access to select applications:

    • 🔥 Pabbly Connect — Lifetime Access for $249View Offer
    • 🔥 Pabbly Subscription Billing — Lifetime Access for $249View Offer
    • 🔥 Pabbly Chatflow — Lifetime Access for $249View Offer

    Make a one-time investment and enjoy the advantages of robust business management tools for years to come.

Random selection of a file on a GDrive

I want to achieve to randomly select a single file in a specific folder on GDrive.
I have issues with multiple problems, here and would kindly ask for hep from the pros on the group.

Problem 1 - knowing how many files are in the folder: When I look at the response that comes back from "Google Drive List Folder Content" command, I do not identify a key that holds the value of the amount of files inside the folder. If that doesn't exist, I guess we have to "count" the files somehow. I tried the iterator, but it needs an array as json and the GDrive responds is not shown as an array. What can I do here? Is there a way to convert the entire GDrive response into an array? Are there other ways to iterate through GDrive files or some other way to count them? Is there a way how to find the highest number seen in any "key"(not "value")?

Next I have to generate a random number between 1 and the prior-step-result-number. This seems easy with RANDBETWEEN(1, [prior-step-result-number]). No need for help.

Problem 2 - selecting the final result: Now, I got the random number and want to use that particular file in the next step of my flow. It is not clear to me how to map that file. As GDrive list response does not give me a key/value pair for a certain file count I need to select the file through it's name or Id, but the number I am looking for is not in any "value" but only in a "key". And ideas how to solve this?

I am very much looking forward to your kind help.
Greetings form Berlin!
 

ArshilAhmad

Moderator
Staff member
Hi @TechVentury,

Google Drive does not provide a specific number(count) for a particular file in a specific folder in 'value'. While you do receive the number of files in the response 'key', it is not possible to use that number to specify a file. Therefore, I am afraid the use case you are describing does not appear to be possible.

Problem 1 - knowing how many files are in the folder: When I look at the response that comes back from "Google Drive List Folder Content" command, I do not identify a key that holds the value of the amount of files inside the folder. If that doesn't exist, I guess we have to "count" the files somehow. I tried the iterator, but it needs an array as json and the GDrive responds is not shown as an array. What can I do here? Is there a way to convert the entire GDrive response into an array? Are there other ways to iterate through GDrive files or some other way to count them? Is there a way how to find the highest number seen in any "key"(not "value")?
To capture responses in the form of JSON, you need to disable the Simple Response.
1705272235523.png


Problem 2 - selecting the final result: Now, I got the random number and want to use that particular file in the next step of my flow. It is not clear to me how to map that file. As GDrive list response does not give me a key/value pair for a certain file count I need to select the file through it's name or Id, but the number I am looking for is not in any "value" but only in a "key". And ideas how to solve this?
As mentioned in my initial statement, Google Drive doesn't give us the file count in 'Value', so getting the count in 'value' is not possible.
 
Top