If you just want to add the magic number back to the class files, you could use a simple shell script for this (assuming you are on Linux, or have Cygwin on Windows).
First create a file with just the 4 bytes of the header (CAFEBABE).
Then, extract the class files from the jar to some directory, and run this command at the root:
find . -name "*.class" | while read file; do
mv ${file} ${file}-old
cat /path/to/file/with/header ${file}-old > $file
rm ${file}-old
done
Note: The above script works in bash, but you should be able to write something similar for any shell, or even for Windows.
But what do you mean by "have their magic number and type removed"? If the bytecode has been mangled in any way, the changes might be much more difficult to fix if not impossible.