How To Set Expiration Date for Google Drive Shared Links

Editor Ratings:
User Ratings:
[Total: 0 Average: 0]

This tutorial explains how to set expiration date for links shared for Google Drive files. Using this , you can set sharing links, used to share files and folders stored in your Google Drive  with others, to automatically expire after a specified time duration.

In normal cases, any links that you use to share your files and folders in Google Drive remain active, unless you manually revoke others’ permissions to access the stuff shared in your Drive account. And that is why there are online services like Torpedo that we have to use in case we want to share files with self-destructing links.

But now you can set expiration date for such links in Google Drive. Since this isn’t a functionality Google Drive natively offers, we’ll be using a little bit of Google Scripts magic. Sounds cool, doesn’t it? Let’s see how this works:

custom scripts header

Part 1: How to invite others to share the files/folders stored in your Google Drive account?

Step 1: Before even getting started with the process, you’ll need to specify the folder/file in your Google Drive account that you want to share with others. For the purpose of this tutorial, I’ll be using a sample folder named Sample Shared Folder, consisting of two uploaded files.

shared folder in drive

Step 2: Select the folder, and add people who’ll be able to access it by clicking the sharing button on the top right corner. You can add people through their email addresses. Also, keep note of the unique sharing link that’s automatically generated, as this is the link that the collaborator(s) will need to click on, to be able to share the files/folders. Check out the screenshot below

shared folder sharing invites

That’s it. Once the collaborator(s) click on the sharing link, they can access the files/folders. But that’s where the problem arises. The sharing link (discussed above) will remain active forever, and thus the people you have invited to collaborate on the files/folders can access them as long as they have the unique link.

This is where the second stage of this process, where you can set the sharing link to auto-expire after a specified duration, comes into play. Here’s how:

Part 2: Using the Custom Google Script to auto-expire the sharing link

Step 1: It’s time for the Google Custom Script to work its magic. But first of all, you need to get this custom Google script, which is just a tiny snippet of code that executes in the cloud. The custom Google script can be directly accessed by clicking here.

Step 2: Once you do that, the script will automatically open up via Google Drive. Here’s how it looks like:

custom google script

As illustrated by the above screenshot, the custom Google Script has two parameters that you have to modify to make it work for the shared folder in your Google Drive account. One of these parameters is the public Google Drive file or folder URL, and the other is the link expiry time and date.

Step 3: Now comes the real work. First of all, you have to change parameter var URL by replacing the URL in quotes, by your shared file/folder’s unique link (discussed during Step 2 of Stage 1). Similarly, you have to change the parameter var EXPIRY_TIME by replacing the values in quotes with the date and time that you want the link to your shared file/folder to expire, in YYYY-MM-DD HH:MM format.

For example, if you want the sharing link to expire on May 03, 2014 at 15:00 hrs., enter 2014-05-03 15:00

Step 4: Once you’re done making the changes, you need to authorize the script to run at the specified time and date. To do that, go the Menu Bar, and select Run –> Start. After that, a confirmation prompt will ask you to authorize the script to run. Click Continue.

run the script

That’s it. Once you authorize the script to run, it’ll automatically disable the sharing link at the specified time and date. Now that wasn’t that hard, was it?


Google Drive is an indispensible tool for collaborators, more so for those who are strongly invested in Google’s ecosystem. But the limitation of the sharing links staying active forever poses a privacy risk. Thankfully, custom Google scripts like the one discussed in this article are there to help, and make adding these much needed features to an other wise amazing web app a breeze. I suggest you give it a try, you won’t be disappointed.

via Digital Inspiration

Image Courtesy: Keiichi Yasu via Flickr


Editor Ratings:
User Ratings:
[Total: 0 Average: 0]

Leave A Reply


Get 100 GB FREE

Provide details to get this offer