Determine file type (binary or text)

Sami Viitanen none at none.net
Thu Aug 14 04:30:08 EDT 2003


I think I've found what I need.

The module is called magic.py.

It show if the file is data or text.

It can be downloaded from http://www.demonseed.net/~jp/code/


"Sami Viitanen" <none at none.net> wrote in message
news:gwH_a.1649$k4.34358 at news2.nokia.com...
> Thanks for the answers.
>
> To be more specific I'm making a script that should
> identify binary files as binary and text files as text.
>
> The script is for automating CVS commands and
> with CVS you have to add the -kb flag to
> add (or import) binary files. (because it can't itself
> determine what type the file is). If binary file is not
> added with -kb the results are awful.
>
> Script example usage:
> -import.py <directory_name>
>
> Script makes list of all files under that directory
> and then determines each files filetype. After that
> all files are added with Add command and binary
> files get that additional -kb automatically.
>
>
> "Sami Viitanen" <none at none.net> wrote in message
> news:AFm_a.9725$g4.189983 at news1.nokia.com...
> > Hello,
> >
> > How can I check if a file is binary or text?
> >
> > There was some easy way but I forgot it..
> >
> >
> > Thanks in adv.
> >
> >
>
>






More information about the Python-list mailing list