This seems to be similar to this question except that you require the files to be renamed in addition to simply identifying them. This can also be done with the same tool (TrID - File Identifier) that is mentioned in that question.
TrID is an utility designed to identify file types from their binary signatures. While there are similar utilities with hard coded logic, TrID has no fixed rules. Instead, it's extensible and can be trained to recognize new formats in a fast and automatic way. The definitions file (also downloadable from the same website) currently as 5000+ filetypes.
You can use command TrID on the command line with the -ae switch to instruct TrID to rename the files after identification. For example:
C:\TrID>trid c:\temp\* -ae
Output:
TrID/32 - File Identifier v2.20 - (C) 2003-15 By M.Pontello
Definitions found: 5702 Analyzing...
File: c:\temp\FILE0001.CHK
75.8% (.BAV) The Bat! Antivirus plugin (187530/5/21)
File: c:\temp\FILE0002.CHK
77.8% (.OGG) OGG Vorbis Audio (14014/3)
File: c:\temp\FILE0003.CHK
86.0% (.DOC) Microsoft Word document (49500/1/4)
File: c:\temp\FILE0004.CHK
42.6% (.EXE) UPX compressed Win32 Executable (30569/9/7)
4 file(s) renamed.