When you share any folder or file in Google Drive with someone, the shared links will work forever until you manually change the sharing permissions. What if you want to share a folder in your Google Drive for exactly 24 hours and automatically make the folder private after that period? Or share a Google Docs spreadsheet for a week and then remove access to other users?

Google Drive does not offer an option but you can easily can add an auto-expiry date to any of your shared files and folders with the help of a simple Google Script. The script works for both Gmail and Google Apps accounts.

Google Drive Shared Folders

Set Expiration Dates & Temporarily Share Google Drive Files & Folders

You have a file or folder in Google Drive that you have shared either with Public or with a specific set of users. You can specify a date and time when you want the shared links to expire.

The script will run at the specific time and remove all the sharing permissions from your file or folder making them private and the old links would no longer work. Here’s how you can use the script.

  1. Click here to make a copy of the Google Script into your Google Drive.
  2. Add the URL of your shared Google Drive folder or a file in Line #3 and the expiration date in Line #7 (use the YYYY-MM-DD HH:MM format).
  3. Go to Run -> Start and authorize the auto-expiry script to run at the specified time.

That’s it. You can exit the Google Script page and it will automatically disable the sharing options for that file /folder at the given date and time.

The script runs in your own time zone but if that’s not the case, you can choose Project Properties under the File menu in the Script Editor and change your default time zone. Remember to save your settings.

Awesome Google Scripts → Custom Google Scripts →