One way I do it is to open it in notepad and look at the first few characters or if theres nothing identifable there look a the very end of the file.
If at the beginning of file:
MZ = EXE
PDF = errmm PDF
MSCF = Microsoft Cab File
CWS = shockwave Flash (SWF) file
BM = BMP file
End of File
Microsoft Office Word Document, MSWord, Word.Document = MS Word document
W o r k b o o k, Microsoft Excel (slightly higer up the file) = MS Excel
I've got a list of some more on my work computer that I can post up if needed but it's quite easy to work them out.
One way to automate it would be to do a patern match in a batch file for example.