Teacher at fault
There was nothing wrong with the student trying to automate a script to do it right. Doing it by hand individually is the wrong way to go, and is more likely to cause problems. The problem is the teacher did not explain anything to the student first, so that he would have known how to do it safely, accurately, and more quickly.
And it is foolish to pretend there was any danger, risk, or that the source files has to be rebuilt by hand.
ALL multi user systems are always backed up every night.
And restoring the back up was the correct way to fix the mistake.
The student should have been told about that.
And in fact, the student should have been told to make a script first to do a localized back up of all that he was supposed to copy, first.
He also should have been warned about side effect, and his scripts should have been checked by hand first by the teacher.
The fault is entirely with the teacher and not the student.