How to Delete Google Drive Files Automatically: Two Methods
Deleting our old Google Drive files can help us dramatically free up storage space. This is useful for two reasons.
First, it’s how we keep Google Drive neat and efficient in case we no longer need those files.
Second, deleting files can help you remain on Google One’s free plan, which is limited to 15 GB of storage space.
However, there’s an issue: Google doesn’t offer a good native option for deleting Google Drive files automatically.
To do so, we’d need to manually:
Identify the files we want to delete.
Move them to Trash, where they’ll be deleted in 30 days.
This is too much work, especially if your unwanted files are scattered across multiple folders (and subfolders, and sub-subfolders).
The quicker solution is to use Make to automatically find our old Google Drive files and delete them on the spot.
We’ll walk you through the steps for doing so in this tutorial.
In addition, we’ll share an alternative method that lets you review the condemned files before they’re deleted for good - just in case you change your mind at the last minute.
Both methods work on Google Drive files and folders, which we’ll collectively refer to as “files” for convenience.
So, sign up for a Make account, and let’s clean up your Google Drive!
Method 1: Automatically delete old Google Drive files
The first method is straightforward: It finds Google Drive files that haven’t been modified since a certain date and then deletes them.
To get it to work, we’ll only need to set up a simple, two-module scenario in Make.
For this tutorial, we’re going to delete all Google Drive files that haven’t been modified in the last six months. Feel free to change this time frame to meet your needs!
1. Set up the Make scenario and the first Google Drive module
Start by creating a new Make scenario, and then add the Google Drive > Search for Files/Folders module to it.
Connect the module to your Google account, then configure its settings like this:
Select the Method: Set this to Select from the list.
Choose a Drive: Choose the Google Drive that Make should search for old files (such as “My Drive”).
Choose a Folder: Choose the Google Drive folder that Make should search for old files. Leave this setting blank if you want Make to search the whole of your selected Drive. If you’ve chosen a folder here, you’ll need to set the "Add the folder selected above to the query<folder ID> in parents" setting below to Yes (more on this shortly).
Retrieve: Choose whether you want Make to search for Google Drive files, folders, or both.
Search: Set this to Enter custom search query.
Query: Fill this out with modifiedTime<='{{addMonths(now; -6)}}' to search for Google Drive files last modified six months before the date of running the scenario or earlier. Be sure to use single, straight quotation marks in your query (curly quotation marks will not work).
Add the folder selected above to the query<folder ID> in parents: Set this to No if you want Google Drive to search for old files across your entire selected Drive. This includes folders outside of the folder you may have selected for the Choose a Folder setting, and that folder’s subfolders. Set this to Yes if you want Make to search for old files in just the folder you’ve selected for the Choose a Folder setting earlier. With this Yes setting, however, any subfolders you have in the selected folder will not be searched.
Limit: Fill out the maximum number of old Google Drive files Make should find when the scenario is run, such as “50.” Leave this setting blank if you don’t want to impose a cap, but bear in mind your scenario may fail if Make finds and has to list an extremely large number of files.
After you finish configuring this module, click OK, and move on to the next step.
2. Delete your old Google Drive files
Next, add the Google Drive > Delete a File/Folder module to your Make scenario.
Again, connect this module to your Google account.
Start configuring it by leaving the Enter a File/Folder ID and Select File/Folder settings as Enter manually and File, respectively.
Then, map the “File ID” item from the previous Google Drive module to the File ID setting (check the image below for reference).
Once ready, click OK to finish configuring this module.
Note: Google Drive will still delete any old folders it finds even though the Select File/Folder setting is set to File and not Folder.
3. Test and activate your scenario
We’ve set up the scenario, now it’s time to test it.
Doing so can be a little tricky because deleted files are gone forever, and you don’t want to accidentally delete a file you may still need.
So, we suggest testing the scenario on just one file.
First, right-click the Google Drive > Search for Files/Folders module and select Run this module only.
The module will display a list of Google Drive files last modified at least six months ago.
Review the list to confirm this is the case, and pick one of these files being 100% sure you don’t need it.
Then add its file name to the query in the Google Drive > Search for Files/Folders module’s Query setting, like so:
modifiedTime<='{{addMonths(now; -6)}}' and name='insert your file name here'
Note: The file name is case-sensitive. You’ll also need to include the file’s extension and use single, straight quotation marks as mentioned earlier. Check the image below for reference.
Next, click the Run once button at the bottom of the scenario builder to run the automation in full.
If Make deletes that specific Google Drive file, your scenario works perfectly.
Now, remove the file’s name from your custom search query.
Click the Run once button again, and Make will find and delete all your other old Google Drive files at once.
You can also schedule your scenario and then turn it on to set up how often you want Make to automatically find and delete old Google Drive files in the future.
Method 2: Automatically send old Google Drive files to Trash
Instead of automatically deleting our old Google Drive files, we can get Make to send them to Google Drive’s Trash bin.
Google Drive automatically deletes files in Trash - but only 30 days later. This gives us time to restore any files we don’t want to delete in the glimpse of an eye.
Here, we’ll also modify our scenario so it sends us a Slack message of the Google Drive files that have been sent to Trash.
This way, we’ll be alerted of files in the Trash bin, allowing us to manually rescue files if we need to.
Here’s how to set up such a Make scenario for yourself.
1. Create a new Make scenario and add the first Google Drive module
This first step is the same as that for Method 1, so we won’t repeat it in detail here.
In short - start a new Make scenario, add the Google Drive > Search for Files/Folders module to it, and configure the module in the same way mentioned above.
2. Add the second module to move your old Google Drive files to Trash
Next, add the Google Drive > Move a File/Folder to Trash module.
Connect this module to your Google account and leave the Enter a File/Folder ID and Select File/Folder settings as Enter manually and File, respectively.
Map the “File ID” item from the previous Google Drive module to the File ID setting.
Once ready, click OK and move on to the next step.
3. Compile a list of the Google Drive files that have been moved to Trash
To do so, add the Text aggregator module to your scenario.
Enable the Show advanced settings switch, then configure the module like this:
Source Module: Set this to Google Drive - Search for Files/Folders [1].
Row separator: Set this to New row to display each file in a new row.
Stop processing after an empty aggregation: Check the Yes checkbox so that the scenario will stop if no Google Drive files are moved to Trash.
Text: Map the “Name” item from the Google Drive > Move a File/Folder to Trash module here. You can also add list formatting such as “• ” or “- ” before the “Name” item to make your list look more list-like.
Ready? Click OK to finish configuring the module.
4. Add a filter in between the two Google Drive modules
Due to us adding the Text aggregator module, the scenario will continue to run - and produce an error - if Google Drive doesn’t find any old files in the first step.
We can prevent this from happening by adding a filter that lets the scenario continue only if old files are found.
In between the two Google Drive modules, click the wrench icon > Set up a filter.
Give your filter a descriptive label (such as “Proceed only if files are found”), then set up the condition’s first operator as the “File ID” item from the first Google Drive module.
Click the Text operators: Equal to setting and change it to Basic operators > Exists.
Then, click OK and move on to the next step.
5. Send yourself the list of the Google Drive files that have been moved to Trash
Finally, let’s create the notification that sends us the list of trashed Google Drive files.
We’ll do so by adding the Slack > Create a Message module and connecting it to our Slack account. (Feel free to replace Slack with other team messaging apps available on Make).
Then, select the Slack channel in which you want to receive the notification.
Fill out the Text field with your message contents. When doing so, insert the text aggregator module’s “text” item where you want your list of trashed files to appear. See the image below for reference.
Optional: Enable the Show advanced settings switch to customize your message’s icon emoji and username.
With that, the setup is complete! Here’s how your scenario should look:
Finally, test your scenario by clicking the Run once button.
Note: If you want to test your scenario on just one file instead of potentially all your old files, add that file’s name to your custom search query. More details on this in step three of our tutorial for Method 1 above.
Check if you receive a message about your Google Drive files having been moved to Trash, and that they’ve actually been moved there.
If so, schedule your scenario to set up how often you want to automatically move your old Google Drive files to Trash, activate your scenario, and you’re done.
Out with the old Google Drive files, in with the new
Thanks to Make, automatically deleting your Google Drive files is a reality.
What’s more, you can customize the process in the exact way you want it to work. And doing all this takes only a few minutes.
Start by signing up for a Make account here. You’ll be saying sayonara to your old files - and hello to all that beautiful freed-up storage space before you know it.