## Set the contentprof_path to the .contentprof file you want to edit ## Set the new_size to any value you want. If its a size tag, ## it'll be a number, if it's style tag, it'll be regular, bold or italic import BeautifulSoup import os.path #parse the .contentproj file for spritefont paths contentprof_path = r"C:\path\to\GameContent.contentproj" #pull out the dir name directory = os.path.split(contentprof_path)[0] #the new font size new_size = 16 #the tag to change tag_to_change = "size" #---------------------------------------------------------------------- def ParseXMLtoStoneSoup(path): """loads a given xml file path into a BeautifulStoneSoup object""" with open(path) as f: contentprof_content = f.read() soup = BeautifulSoup.BeautifulStoneSoup(contentprof_content) return soup #---------------------------------------------------------------------- def changeTag(soup, tag, newValue): """changes a given tag's string to newValue""" #find the size tag foundTag = soup.find(tag) #change the value, convert to string foundTag.setString(str(newValue).lower()) soup = ParseXMLtoStoneSoup(contentprof_path) #look for all the tags 'compile' compileTags = soup.findAll("compile") #save all the spritefont file names spriteFonts = [] for tag in compileTags: spriteFonts.append(directory+ r"\\" + tag['include']) #you can check for path validity however you would like #print "Here are the relevant spritefonts." #for path in spriteFonts: #print path ##now we've got the filepaths, time to open each up and edit the proper tags for path in spriteFonts: #load one font into BeautifulStoneSoup spriteFontSoup = ParseXMLtoStoneSoup(path) changeTag(spriteFontSoup, tag_to_change, new_size) #save the new file with open(path, 'w') as f: f.write(spriteFontSoup.prettify()) print "changed", path print "Done!"