When you share a folder or a file in Google Drive with anyone, the shared links will stay active forever until you manually change the access permissions. There isn’t a way to set an expiration date for your shared files or folders that will make these links unavailable after a certain date and time.

You can however add an auto-expire feature to any of your shared folders in Google Drive with the help of a simple Google Script.

Google Drive Shared Folders

Set Expiration Dates & Temporarily Share Google Drive Folders

You create a folder in Google Drive and share it with Public or a small group. You then specify a date/time when you want that shared link to expire. The script, at the specified time, will create a copy of your shared folder and delete the original one. Thus the shared links would no longer work though the folder and files will stay in your Google Drive.

Let’s get this to work now.

  1. Open the Google Script and then choose File -> Make a Copy to copy this script into your Google Drive.
  2. Add the URL of your shared Google Drive folder and the expiration date in the script (use the YYYY-MM-DD HH:MM format).
  3. Go to Run -> Initialize and grant the necessary permissions.
  4. Go to Run -> Start and it will create a trigger that will auto-expire the shared links at the specified time.

That’s it. You can exit the Google Script page and it will send you an email notification when the shared links are disabled.

The Google script can be used for setting expiry dates against shared folders only but not for individual files due to certain limitations in Google Apps Script. Thus, in case you wish to auto-expire an individual file, just put in a new folder and share that entire folder.