Skip to content

Instantly share code, notes, and snippets.

View pan-long's full-sized avatar

Pan Long pan-long

  • Google
  • Singapore
View GitHub Profile
@pan-long
pan-long / DriveIndef.gs
Last active April 15, 2019 15:00
Remove old Drive files unless it has "#Indef" in its description.
var INDEF_LABEL = '#Indef';
var RETENTION_DAYS = 365;
var RETENTION_DATE = new Date();
RETENTION_DATE.setDate(RETENTION_DATE.getDate() - RETENTION_DAYS);
function DriveIndef() {
var root = DriveApp.getRootFolder();
RemoveOldFiles(root);
@pan-long
pan-long / GmailIndef.gs
Last active April 15, 2019 14:55
App Script to move old Gmail threads to Trash
function GmailIndef() {
var INDEF_LABEL = 'Indef';
var RETENTION_DAYS = 356;
var RETENTION_DATE = new Date();
RETENTION_DATE.setDate(RETENTION_DATE.getDate() - RETENTION_DAYS);
var threads = GmailApp.search('in:anywhere'
+ ' -(label:' + INDEF_LABEL + ')'
+ ' before:' + RETENTION_DATE.getFullYear()
## Setup
# * Create a room with yourself
# * Add a Webhook. Click 'Configure Webhook' in dropdown of your room name. Add a webhook and copy the URL.
# * Put the webhook URL into <Chat Webhook URL> in the code. Copy the code to
# .bashrc
## Usage:
# ```
# sleep 3; hc
# ```