| [reply] |
I think you can check the first few bytes/characters of the file, to see whether they're simple text, or .DOC format. It appears that the first few characters in a Word .DOC file are ÐÏࡱá, which do not in general resemble what you find in text files. I don't know how reliable this is, but my guess is that Word docs will have some odd characters in them early on, and that could be a way of identifying the type independent of the extension.
| [reply] [d/l] |
Hi Sandeep,
This is a lame solution.You can always use the Win32 OLE object to read both txt and doc.
The extenion type does not really matter.
Hope this helps.
thanks,
roop | [reply] |
use File::MMagic;
my $path='/path/to/file.doc';
my $mm= new File::MMagic; #use internal magic file
my $t = $mm->checktype_filename("$path");
# $t holds mime type- doesn't matter what the file extension or no ext
+ension is
| [reply] [d/l] |
Dear Monks
'MMagic' as well as 'file <namefile>' (on Linux) are really good solutions
Thanks to all for the suggestions
Regards,
Sandeep
| [reply] |
I suppose you work on M$ Windows platform.
Windows work with file extension... I don't
know an answer, but you can watch this link http://gnuwin32.sourceforge.net/packages/file.htm
However, with GNU/Linux (I suppose in all Unix-like), you can
write in shell
file namefile
and you get information with file, also MS Windows file. | [reply] [d/l] |