Set an Auto-Expiry Date for Shared Files and Folders in Google Drive
You can set an end date for your shared folders and files in Google Drive and the sharing links will be automatically disabled at the automatic date and time.
When you share a folder or a file with someone in Google Drive, the share links will work until you manually change the sharing permissions. What if you want to share the folder for exactly 24 hours in your Google Drive and automatically make the folder private after that period? Or share Google Docs spreadsheets for one week and then remove access to other users?
Google Drive does not offer an option but you can easily add an auto expiration 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 end dates and temporarily share Google Drive files and folders
You have a file or folder in Google Drive that you shared with either a public or specific set of users. You can specify a date and time when you wish to end the shared link.
The script will run at specific times and will make all sharing permissions private to your file or folder and the old links will no longer work.
1. Create a copy of Google Script in your Google Drive.
2. URL of your shared Google Drive folder or a file in line # 3 and add end date in line # 7 (use YYYY-MM-DD HH: MM format).
3. Run -> Start and authorize the automatic termination script to run at specified times.
You can exit the Google Script page and will automatically disable the sharing option at that date / time given for that file / folder.
The script runs in your time zone, but if not, you can select project properties under the File menu in the script editor and change your default time zone. Remember to save your settings.