Search for AVI file?

John Lenton john at grulic.org.ar
Mon Aug 30 16:33:10 EDT 2004


On Mon, Aug 30, 2004 at 10:23:05PM +0200, Peter Kleiweg wrote:
> Peter Kleiweg schreef:
> 
> > John Doe schreef:
> >
> > > I realise that this is not really a python question, but python's the
> > > only language I'd be comfortable trying to deal with this.
> > >
> > > What I need is to search a drive and find all the AVI format files
> > > that are NOT listed with the AVI extension.  I'm looking over an old
> > > drive of mine from an old computer.  I know the files were renamed
> > > with the wrong extension, but I know that they were originally AVI
> > > files.  Can python do this for me?  Any hints?  Anybody have a link to
> > > something that would already do this?  I appreciate any help.
> >
> > Use walk() to find all files. Open each file and read in the
> > first 12 bytes. The last four of those 12 bytes should be
> > 'AVI ', if I'm not mistaken.
> 
> Or from the command line:
> 
> find / -type f -exec file '{}' ';' | grep AVI

if that's GNU find, you'll find

    find / -type f -print0 | xargs -0 file | grep AVI

a lot faster, usually.

-- 
John Lenton (john at grulic.org.ar) -- Random fortune:
Them as has, gets.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: Digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20040830/45b50d57/attachment.sig>


More information about the Python-list mailing list