Change Folder Permissions with Google Apps Script

This Google Apps Script will change the access permissions of the specified Google Drive folder from Public to Private at a custom date and time. When you initialize the script, it creates a time-based trigger that is responsible for change the shared permissions.

Google Scripts has a simple file.removeViewer(user) method to remove one or more users from a shared File but it doesn’t seem to work when the file /folder is shared with Public. Thus the workaround, as used in this script, is to create a copy of the shared folder and delete the original one thus expiring the shared links.