It's not a html related topic. You should use a programming language.
- Creat a program.
- Loop through each of your html files.
- Replace the desired lines of code (or any other string) with your new content.
By the way if your purpose is just to manipulate a bunch of classes/IDs and content, it's doable with javascript/jQuery. but unlike first solution it will run each time one of your html files are loaded in a browser. i don't recommend this.