The lack of representational diversity and role models in physics, including in our textbooks and curricular materials, is an oft-cited contributing factor to the continuing dramatic under-representation of women and people of color in physics. In this work, we develop an automated, Python-based tool for identifying the names and demographics of scientists who are mentioned in indices and chapters of physics textbooks, enabling authors, publishers, and users of physics textbooks to rapidly analyze the demographics of these texts. We quantitatively validate the automated tool using standard machine learning metrics, attaining high accuracy, precision, recall, and F1 scores. The tool is then used to demonstrate two of the many potential applications: examining whose work is mentioned in the entire collection of textbooks used in a representative four-year undergraduate physics major curriculum as well as an analysis of the demographics of scientists mentioned in a selection of ten introductory physics textbooks. Both of the sample analyses result in a similar portrait, showing that the undergraduate physics textbooks examined in this work focus overwhelmingly on work attributed to White men of European, British, and North American descent. This work points to an urgent need for the physics education community, including textbook publishers, authors, and adopters, to work together to broaden our portrayals of physics to reflect the vast diversity of scientists, both historically and contemporaneously, who are working in this field.