Here's the guide from Digital Inspiration:
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.
http://www.labnol.org/internet/auto-expire-google-drive-links/27509/