understand program used to create file
Chris Angelico
rosuav at gmail.com
Tue Nov 1 16:53:47 EDT 2011
On Wed, Nov 2, 2011 at 6:27 AM, pacopyc <pacopyc at gmail.com> wrote:
> Hi, I have about 10000 files .doc and I want know the program used to
> create them: writer? word? abiword? else? I'd like develop a script
> python to do this. Is there a module to do it? Can you help me?
>
Technically, you can't find out just from the file what it was that
created it. But if you mean "figure out what type of file each one is"
(eg recognize an ODF, a PDF, a DOC, etc), then the easiest way is to
read in the first few bytes of the file and look for well-known magic
numbers[1]. As Dave says, Linux comes with a command that does exactly
that (and a bit more), called 'file'.
ChrisA
[1] http://en.wikipedia.org/wiki/Magic_number_(programming)
More information about the Python-list
mailing list