finding files by type

how do you find all files on a system that have a certain extension?

Like find all files that have a .doc extension.

Comments

  • : how do you find all files on a system that have a certain extension?
    :
    : Like find all files that have a .doc extension.

    If you have the newest version of Python, you can use the new os.walk function.

    [code]
    >>> from os import walk
    >>> from os.path import join
    >>> for dir, subdirs, files in walk("K:srcsql"):
    ... for file in files:
    ... print join(dir, file)
    ...
    [/code]

    If you have an older version of python, there is os.path.walk which is not as efficient. The newer version is an iterator generator, so it is far more efficient and actually easier to use because you don't have to pass a function to it.


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion