Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'filename': 0.09; 'jpg': 0.09; 'python': 0.11; 'def': 0.12; 'attempted': 0.16; 'direction?': 0.16; 'skip:{ 30': 0.16; 'subject:File': 0.16; 'trying': 0.19; 'to:name:python-list@python.org': 0.22; 'print': 0.22; "aren't": 0.24; 'tells': 0.24; 'file.': 0.24; "i've": 0.25; 'script': 0.25; 'point': 0.28; "i'm": 0.30; 'file': 0.32; 'basic': 0.35; 'common': 0.35; 'but': 0.35; 'checks': 0.38; 'to:addr :python-list': 0.38; 'files': 0.38; 'little': 0.38; 'anything': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'how': 0.40; 'first': 0.61; 'from:addr:msn.com': 0.97 X-TMN: [MFhw/lJ/kflWH1J+PFbbtcpRBsdi7d5P] X-Originating-Email: [jadec375@msn.com] Content-Type: multipart/alternative; boundary="_f50a5216-a205-4a31-829c-e937f2ea762f_" From: jade To: "python-list@python.org" Subject: Checking Common File Types Date: Sun, 1 Dec 2013 18:27:16 +0000 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 01 Dec 2013 18:27:16.0582 (UTC) FILETIME=[F66E6860:01CEEEC2] X-Mailman-Approved-At: Sun, 01 Dec 2013 22:55:11 +0100 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 61 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1385934912 news.xs4all.nl 15985 [2001:888:2000:d::a6]:37704 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:60841 --_f50a5216-a205-4a31-829c-e937f2ea762f_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hello=2C=20 I'm trying to create a script that checks all the files in my 'downloaded' = directory against common file types and then tells me how many of the files= in that directory aren't either a GIF or a JPG file. I'm familiar with bas= ic Python but this is the first time I've attempted anything like this and = I'm looking for a little help or a point in the right direction?=20 file_sigs =3D {'\xFF\xD8\xFF':('JPEG'=2C'jpg')=2C '\x47\x49\x46':('GIF'=2C= 'gif')} def readFile(): filename =3D r'c:/temp/downloads' fh =3D open(filen= ame=2C 'r') file_sig =3D fh.read(4) print '[*] check_sig() File:'=2Cfil= ename #=2C 'Hash Sig:'=2C binascii.hexlify(file_sig)=20 RegardsJade =20 = --_f50a5216-a205-4a31-829c-e937f2ea762f_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hello=2C =3B

<= div>I'm trying to create a script that checks all the files in my 'download= ed' directory against common file types and then tells me how many of the f= iles in that directory aren't either a GIF or a JPG file. I'm familiar with= basic Python but this is the first time I've attempted anything like this = and I'm looking for a little help or a point in the right direction? = =3B


file_sigs =3D {'\xFF\xD8\x= FF':('JPEG'=2C'jpg')=2C =3B
 =3B'\x47\x49\x46':('GIF'=2C'= gif')}

def readFile():
 =3B  =3B= filename =3D r'c:/temp/downloads'  =3B
 =3B  =3B fh = =3D open(filename=2C 'r') =3B
 =3B  =3B file_sig =3D = fh.read(4) =3B
print '[*] = check_sig() File:'=2Cfilename #=2C 'Hash Sig:'=2C =3B
=
binascii.hexlify(file_sig) =3B

Rega= rds
Jade



<= /div>

 =3B

 =3B
= --_f50a5216-a205-4a31-829c-e937f2ea762f_--