Download Recent File From Google Drive

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).

Many Thanks


sorry n8n version am using is 1.29.1

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hey @villa1980, welcome to the n8n community!

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:

Here’s my workflow:

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

No problem! You can use the Google Drive/Download File action for that.

cool, ok, how would I do that especially if i want the most recent file…

There’s a node for that :slight_smile:


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??

1 Like

Hey @villa1980,

You would pass the file ID using something like {{ $ }} so your workflow would look something like the below.

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.

1 Like

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?

1 Like

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

1 Like

Awesome. I’m sure n8n is going to save you a ton of time with your work, enjoy!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.