473,651 Members | 2,750 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Search for AVI file?

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.
Jul 18 '05 #1
6 2438
John Doe wrote:
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.


Have you looked for and found information about the AVI file
format? Google can help you with that.

You should easily be able to use Python to read the first
X bytes of a given file and check the signature to see if
it's likely an AVI file. I'm sure there are exceptions
and new versions and such things, but if you have only
a bunch of "old" AVI files, it's quite possible they are
all detectable by doing something like checking that
bytes 0 through 3 are 'RIFF' and bytes 8 through 10 are
'AVI' (that info from a few handy sites on the AVI format).

Basically you could just open the file and do a .read(10)
and compare the result using slices, e.g. data[0:4] == 'RIFF'
and data[8:11] == 'AVI'.

-Peter
Jul 18 '05 #2
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.

--
Peter Kleiweg L:NL,af,da,de,e n,ia,nds,no,sv, (fr,it) S:NL,de,en,(da, ia)
info: http://www.let.rug.nl/~kleiweg/ls.html

The Halloween Documents: http://www.opensource.org/halloween/

Jul 18 '05 #3
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

--
Peter Kleiweg L:NL,af,da,de,e n,ia,nds,no,sv, (fr,it) S:NL,de,en,(da, ia)
info: http://www.let.rug.nl/~kleiweg/ls.html

Jul 18 '05 #4
On Mon, Aug 30, 2004 at 10:12:04PM +0200, Peter Kleiweg wrote:
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.


Correct. According to file(1)'s database, there are two types of AVI:

0 string RIFF RIFF (little-endian) data
[...]8 string AVI\040 \b, AVI [...]
0 string RIFX RIFF (big-endian) data
[...]8 string AVI\040 \b, AVI


(meaning that little-endian AVIs start with 'RIFFAVI ', whereas
big-endian start with 'RIFXAVI ').

HTH

--
John Lenton (jo**@grulic.or g.ar) -- Random fortune:
BOFH excuse #10:

hardware stress fractures

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBM469gPq u395ykGsRAhEKAK CvF9j4UG2rJSUvq u8y/wEQLQn2AwCdEMzm
gUnjoyyIduzUEXA FNOM96Zs=
=O5mF
-----END PGP SIGNATURE-----

Jul 18 '05 #5
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 (jo**@grulic.or g.ar) -- Random fortune:
Them as has, gets.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBM48GgPq u395ykGsRAqIJAK Chh1KE/1yeSurxeF+rzXdO Hc+RKgCgmo6t
SH73unNSrnInGqH yCFZaG6Q=
=uvdU
-----END PGP SIGNATURE-----

Jul 18 '05 #6
On Mon, 30 Aug 2004 22:12:04 +0200, Peter Kleiweg
<in************ *@nl.invalid> wrote:
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.


Ah, os.walk() was exactly what I needed. By the time I read your
response, I had found the 'AVI' signature, but did not know an easy
way to get to all those files.

Thank You.
Jul 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8715
by: Les Juby | last post by:
A year or two back I needed a search script to scan thru HTML files on a client site. Usual sorta thing. A quick search turned up a neat script that provided great search results. It was fast, returned the hyperlinked page title, filename, and the body txt (30 preceding and following words) in context with the search word highlighted. Excellent.! See it working at: http://www.ipt.co.za Just search for "firearm"
2
1821
by: Rafael Nenninger | last post by:
This question has to do with MS file search but it is happening only with ..asp pages, so I though someone programming with .asp pages has experienced the same situation. I'm trying to find .asp pages with a certain table name (i.e. "renewalInfo" ) When I ran the search I get no results. I know that I have that string in a couple of pages. My file system search engine is working fine with other file types, like Word documents, Excel...
1
2715
by: Eric | last post by:
Hi: I have two files. I search pattern ":" from emails text file and save email contents into a database. Another search pattern " field is blank. Please try again.", vbExclamation + vbOKOnly Me.txtEmail.SetFocus Exit Sub End If Me.txtStatusBar.Value = "Parsing..." strEmail = Me.txtEmail.Value
13
1905
by: Ray Muforosky | last post by:
Hello all: Task: I want to do file search, using the "conatining text" option from a web page. How do I search for a file on my local drive containing a certain string, from a web page. That is, how do run the windows search program from a web page. Any help will be appreciated.
4
3366
by: Dameon | last post by:
Hi All, I have a process where I'd like to search the contents of a file(in a dir) for all occurences (or the count of) of a given string. My goal is to focus more on performance, as some of the files could be upwards of 25mb in size and time is important. I don't want to take the route of loading the text of the file into a giant string and searching it, but would rather focus on a performance-minded solution. Any sugesstions for a...
8
1848
by: stunna | last post by:
Hi there, i want to implement a a system to search for a file in a folder using the file name and if its there, i want it to be displayed. I have one through a couple of books on how to implement this but still, it does not open the file. #!C:/Perl/bin/perl use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser); use DBI; use CGI;
1
3266
by: nganglove | last post by:
C++ string search -------------------------------------------------------------------------------- Hello, please can any one help me? I am given an assigment in C++ to read a text file and search for certain words.If those stated words are found, then I should print the enire them including the entire line. Below is an example of such a text file Example text file: Possible failures: -> Member=1, FSce=1, MP=13.16%, atching...
4
2506
by: ravindarjobs | last post by:
hi...... i am using ms access 2003,vb6 i have a form. in that i have 2 buttons 1. start search 2 stop search when i click the "start search" button the fucntion SearchSystem() is called, it will search for a particular file in the computer(searches entire drives).
3
3545
by: =?Utf-8?B?UGVycmlud29sZg==?= | last post by:
Not sure where to post this... Found some interesting behavior in Windows Search (Start =Search =All files and folders =search for "A word or phrase in the file:"). This applies to XP and maybe other Windows flavors. Procedure: 1. Create a simple text file named test.txt. 2. Open the text file in a text editor and add a simple test word such as "blah" (not quotes).
0
10751
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not a new concept, there is a concept called Steganography which enables to conceal your secret...
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1909
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.