473,320 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Is there a function to search the HD

Hi all.

I was wondering if there is an inbuild function in python to search your
harddrives ( Harddisk's) for a file of a speciel type. I mean can I write a
command with 2 parameters ( one being the filetype, and the other the
location on the harddisk where I want to search for the specific file type )

Thank for all input...
Jul 18 '05 #1
3 1025
Peter Jensen wrote:
Hi all.

I was wondering if there is an inbuild function in python to search your
harddrives ( Harddisk's) for a file of a speciel type. I mean can I write a
command with 2 parameters ( one being the filetype, and the other the
location on the harddisk where I want to search for the specific file type )

Thank for all input...

6.1 os -- Miscellaneous operating system interfaces

This module provides a more portable way of using operating system
dependent functionality than importing a operating system dependent
built-in module like posix or nt.

6.1.4 Files and Directories

walk( top[, topdown=True [, onerror=None]])

walk() generates the file names in a directory tree, by walking the tree
either top down or bottom up. For each directory in the tree rooted at
directory top (including top itself), it yields a 3-tuple (dirpath,
dirnames, filenames).
--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
Jul 18 '05 #2
On Tue, 28 Sep 2004 10:37:07 +0200, Peter Jensen <he********@yahoo.com> wrote:
I was wondering if there is an inbuild function in python to search your
harddrives ( Harddisk's) for a file of a speciel type. I mean can I write a
command with 2 parameters ( one being the filetype, and the other the
location on the harddisk where I want to search for the specific file type )


You want os.walk(). There's a simple example of its use here:

http://aspn.activestate.com/ASPN/Coo.../Recipe/279003

--
Cheers,
Simon B,
si************@gmail.com,
http://www.brunningonline.net/simon/blog/
Jul 18 '05 #3
On Tue, 28 Sep 2004 10:37:07 +0200, Peter Jensen wrote:
I was wondering if there is an inbuild function in python to search your
harddrives ( Harddisk's) for a file of a speciel type. I mean can I write
a command with 2 parameters ( one being the filetype, and the other the
location on the harddisk where I want to search for the specific file type
)


On Unix, you may want to call locate to do the searching. This is a lot
faster than walking the file system yourself. You can use os.system to
call locate (see man locate for details).

Jeremy

Jul 18 '05 #4

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

Similar topics

5
by: melissa.lombard | last post by:
I would like to add dynamic text sizing to a website. There will be three text sizes. When the default is used, only the "Increase text size" button is shown. When the maximum size is used, only...
5
by: pembed2003 | last post by:
Hi all, I need to write a function to search and replace part of a char* passed in to the function. I came up with the following: char* search_and_replace(char* source,char search,char*...
3
by: Mike Weathery | last post by:
Hi all I am using the following function in a text entry box: function goToTV() { location.href="http://www.tvguide.com" + "/search/index.aspx?keyword=" + document.search.q.value; return...
0
by: kang jia | last post by:
hi currently i am doing this search function for car booking website. it can search through either car seats or CarModel. it seems it able to do search function, however i small problem occurs to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.