Below is a Google Apps Script that you can use to update all list items in a Google Document to bullets:
function updateListItemsToBullets() {
// Open the active document
var document = DocumentApp.getActiveDocument();
var body = document.getBody();
// Get all paragraphs in the document
var paragraphs = body.getParagraphs();
for (var i = 0; i < paragraphs.length; i++) {
var paragraph = paragraphs[i];
// Check if the paragraph is a list item
if (paragraph.getIndentStart() !== null) { // If paragraph has a start indent, it's part of a list
// Retrieve the list item's attributes
var attributes = paragraph.getAttributes();
// Check if it's part of a list
if (attributes[DocumentApp.Attribute.LIST_ID] !== null) {
// Retrieve the list ID and list item's nesting level
var listId = attributes[DocumentApp.Attribute.LIST_ID];
var nestingLevel = attributes[DocumentApp.Attribute.NESTING_LEVEL] || 0; // Default to 0 if undefined
// Convert the list item to a bullet
body.getListItems().forEach(function(listItem) {
var listItemAttributes = listItem.getAttributes();
if (listItemAttributes[DocumentApp.Attribute.LIST_ID] === listId) {
body.setListItemGlyphType(listItem, nestingLevel, DocumentApp.GlyphType.BULLET);
}
});
}
}
}
}
To use this script:
- Open your Google Document.
- Click on
Extensions
>Apps Script
. - Delete any code in the script editor and replace it with the script above.
- Save the script with a name you’ll remember.
- Run the function
updateListItemsToBullets
by clicking on the run button (play icon) or by selecting the function name and then clicking the run button. - Return to your Google Document, and you should see all list items updated to bullets.
Note: This script will change all types of lists (both numbered and bulleted) to bulleted lists. If you need a more specific script (for example, one that only changes numbered lists to bulleted lists), you might need to add additional checks based on the list’s current glyph type.