Hey, I've done similar things.

You can use system comands with the following

import os
os.system('command here')

You'd maybe want to do something like

dir_name = 'mydirectory'
import os
os.system('ls ' +dir_name + ' > lsoutput.tmp')
fin = open('lsoutput.tmp', 'r')
file_list = fin.readlines()
fin.close()

Now you have a list of all the files in dir_name stored in file_list.

Then you'll have to parse the input with string methods.  They're easy
in python.  Here's the list of them:
http://docs.python.org/lib/string-methods.html

There is probably a better way to get the data from an os.system
command but i haven't figured it out.  Instead what i'm doing is
writing the stdio output to a file and reading in the data.  It works
fine.  Put it in your tmp dir if you're in linux.


[EMAIL PROTECTED] wrote:
> I'm new at Python and I need a little advice.  Part of the script I'm
> trying to write needs to be aware of all the files of a certain
> extension in the script's path and all sub-directories.  Can someone
> set me on the right path to what modules and calls to use to do that?
> You'd think that it would be a fairly simple proposition, but I can't
> find examples anywhere.  Thanks.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to