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 spreadsheet with colleagues 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.
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 shared links would no longer work. Here’s how you can use the script.
- Click here to make a copy of the Google Script into your Google Drive.
- Add the URL (link) of your shared Google Drive folder or any file hosted on Google Drive in Line #3 and put expiration date in Line #7 (remember to use the YYYY-MM-DD HH:MM format).
- Open the File menu, choose Project Properties and select your Timezone from the dropdown. The date and time that you set in the script will use this timezone.
- Go to the Run menu, choose Start and authorize the auto-expiry script to run at the specified time. This is open-source Google Script and none of your data is shared with anyone.
That’s it. You can close the Google Script editor window and it will automatically disable the sharing options for the specified file or Drive folder at the specified date and time. You can even specify sub-folders that are anywhere in the Drive Tree.