I would simply use a regex search & replace on the HTML file for this.
Given input...
<html>
<head>
<title>Whatever</title>
</head>
<body>
<form>
<input name="foo"/>
<input name="bar"/>
<input name="foo-bar"/>
</form>
</html>
..., a regex search on...
name="([a-zA-Z\-]+)"
... and replacement with...
name="$1" id="$1"
...would yield:
<html>
<head>
<title>Whatever</title>
</head>
<body>
<form>
<input name="foo" id="foo"/>
<input name="bar" id="bar"/>
<input name="foo-bar" id="foo-bar"/>
</form>
</html>
The above regex search & replace values use .NET's regex syntax, but they are easily adaptable to Java regex syntax or another regex syntax.
Actually, using the RegexPlanet Java regex tester, I confirmed that the above regex search & replace values should work as-is with an editor or other tool that supports Java regex syntax too.