A Google Apps Script library that automatically deletes Google Sheets named "Untitled" or "Untitled(n)" from the authorized user's Google Drive by moving them to the trash.
Originally built for a school district to keep shared Drive environments clean. Generalized for public use.
When called, deleteUntitledGoogleSheets() searches the authorized user's Drive for spreadsheets with auto-generated default names and moves them to the trash. It matches:
- Exact name
Untitled - Names matching the pattern
Untitled(n)— e.g.,Untitled(1),Untitled(2)
All actions are logged via Logger for review in the Apps Script execution log.
- Open the script project in Google Apps Script.
- Click Deploy > New deployment.
- Choose Library as the deployment type.
- Copy the Script ID from Project Settings — you'll need it in the next step.
- In your calling script, go to Libraries (the
+icon in the left sidebar). - Paste the Script ID and click Look up.
- Select the latest version and choose an identifier (e.g.,
DeleteUntitledSheets). - Click Add.
DeleteUntitledSheets.deleteUntitledGoogleSheets();This library is designed to run on a recurring schedule. To set up a weekly trigger in your calling script:
- In the Apps Script editor, click Triggers (clock icon in the left sidebar).
- Click Add Trigger.
- Set the following:
- Function: the function in your script that calls
DeleteUntitledSheets.deleteUntitledGoogleSheets() - Event source: Time-driven
- Type: Week timer
- Day: Sunday (or your preference)
- Time: Midnight to 1am (or your preference)
- Function: the function in your script that calls
- Click Save.
This library does not require any Script Properties. It operates entirely on the Drive of the Google account that authorized the calling script.
delete-untitled-sheets-library/
├── src/
│ ├── Code.js # Library source
│ └── appsscript.json # Apps Script manifest
├── .claspignore
├── .gitignore
├── LICENSE
└── README.md
MIT © 2025 Alvaro Gomez