How to fix renamed files after virus

One of our friends brought in a computer where a virus had renamed all of his files so that they appeared as a .html file. He had thousands of files so doing this manually was out of the question so he came to us to write a program to do it. Below is the program we used to strip the .html extension recursively from all of his files.

find -name "*.html" -print0 | xargs -0 rename 's/\.html//'

If we knew all of his files had the extension .html appended, then we may have done something like this. But upon closer inspection only some files had been renamed.

find -maxdepth 1 -type f | sed ‘s/.\///g’| grep -E [.] | while read file; do mv $file ${file%%.*}; done

// //