Batch rename Google Drive Docs & Sheets
Fix your "Untitled Documents" and "Untitled Sheets" using some Apps Script to automate a rename, using the file's own contents.
This one's easy...everyone gets lazy sometimes, and ends up with a bunch of "Untitled Spreadsheet" or "Untitled Documents" in their Google Drive files list. This Apps Script will search for those files, and rename them using the file's own contents (document header or body text, or the value in cell A1 of a sheet).
You can adjust the code as you'd like of course, if this doesn't work for your purpose...or you can use this to rename things in batch without using what's in the file's contents too I guess.
- Create a Google Spreadsheet to hold the results (to show what was renamed)
- In the sheet, click the menu for Extensions -> Apps Script
- Copy the code from this repo, and paste it into the Code.gs file
- Copy the code from the email.html file in the same repo, and create an email.html in Apps Script too
- Add the Docs and Sheets "Services" on the left hand. side using the + icon in the "Services" section.
- Update the variables at the top of the script according to your own setup/preference.
- Run the function for setting the sheet headers, which will prompt you to grant permissions for the script to run on your account. Accept these prompts.
- Run the function to find and rename the files, according to. your variable configuration.
- Check the google sheet when it's done to see what it found and what it renamed things to (just in case you need to revert anything manually).
- That's it.
- If you have so many that it takes more than 3.5 minutes to run on your account, you can run it again manually, or set a trigger to run on a schedule. It will email you when it's finished with all the files it finds.
Hopefully it's helpful to people who need to bulk rename their google drive contents easily/efficiently.
Check out my other scripts on github.com/usaussie or techupover.com