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.