Hi,
I am very very very new to n8n (as in starting to build workflows this week).
I have been a task to look into which involves finding the most recent file in a google drive folder and then downloading it.
I am ok with the downloading a file part and on execution on trigger, it is just the finding the most recent file I am stuck on (have not even created a workflow for it yet).
I took a look and couldn’t find a way to sort the results in the Google Drive note itself. However, if you set the options to export all the available fields, you’ll get access to the ‘modifiedTime’ property:
If you then use a ‘Sort’ node and set it to sort by modifiedTime (just the text, not an expression!) and set it to descending, you’ll get the most recently changed files at the top of the results:
That’s brilliant bartv, thank-you for the quick response, makes a lot of sense.
Just to be pain, once I have sorted the folder, how would I download that file that is at the top of the sorted list
This is really good and thank you for adding the images as really helped to understand what to do and how it all comes together.
I have included the Download file from Google Drive node, however it asks for Parameter file and not sure how I would grab the latest file to download. I guess it would involve some sort of JSON??
Thank-you Jon, I had added the node earlier with what you have shown me, but wasn’t sure that by choosing the ID that it would change when a new file is uploaded tomorrow.
Really appreciate you both coming back to me and helping me with this.
You’re welcome! The way it’s set up now is that the ID is taken from the first item in the sorted list of your search results, meaning it should point to the most recently uploaded file, yes.
Please give it a try and let us know if this solved your issue?
Yes that solved the issue and now I have been tasked with a download of the remaining files within the google drive so I will have a go at that.
Once again thank-you for your help