I have a fitness program wich im using Google drive to store my clients info for their Diet/training plans, but im trying to automate these plans because it takes a lot of time.
What is the problem & what have you tried?
The problem is im trying to figure out how to take the last diet file from each client i got.
Example with Folders: Client Alana/ Diet plan N1, Diet plan N2, Diet plan N3
How do i reach to these files and how do i get the ID or get the last diet wich in this case is ‘‘Diet plan N3’’, I tried using my first module of Google Drive search Files/Folder, on wich i could get the ID of the folder of each Client. But with the next module of Google drive search files/folder, i can’t get that last file, i’ve tried everything i know + using some IA with Gemini. Is there any easy way to get that last file.
Forgot to mention that every client are inside a big a folder named ‘‘clients’’, also the files are google doc and i dont have only google docs on every client, i got also other type of files.
do the files follow the same naming convention? Do they always end with N#?
You can use last(split(file_name;space)) to get the N# of the file. Then replace() on top of that to replace N with {{emptystring}} and this will give you the file number.
Aggregate the resulting numbers along with the corresponding file names in an array and sort it to get the largest one. Or skip the file name if you only care about the number to create the next file.
Then just use the name of the sub-folder as the Query, as you are doing. Make sure they match perfectly. Note that you’re mapping an array item withour an index to the Query field. The value will be the first item of Cliente[]. Make sure that’s what you want.
Then, for module 25, you need to set the Id you just retrieved for each client folder in the Folder ID field, in order to search for files inside that folder.
Now comes the tricky part. Google Drive Search for Files/Folders module doesn’t have an orderBy option, so you have two options:
Get all the files inside that folder that match your restrictions (Google Docs filetype only, name contains ‘Diet Plan’, not deleted), aggregate them, then sort by last modified date and extract the first one. Somethinmg like this:
Make sure you choose Enter custom search query and paste in mimeType = 'application/vnd.google-apps.document' and trashed = false and name contains 'Diet Plan'