Someone had already written the same thing in Python, but this one doesn't need a phyton to run and it's really fast, and it writes all the textures that are in "textures", not just those of "blocks" and "entities". However, the exe file only works on Windows.
To use it Navigate to the "Textures" folder, right-click on it and press Copy Path then double-click on texture_list_generator and paste the "Textures" path.