A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/074782.html below:

How to search for and display files in a bunchof subdirectory??

How to search for and display files in a bunchof subdirectory?? How to search for and display files in a bunchof subdirectory??Steve Purcell stephen_purcell at yahoo.com
Tue Apr 17 07:01:35 EDT 2001
Tsang, Edward1 wrote:
> Let say I invoke the script in directory d, but I have abunch of
> subdirectories under d.
> 
> tpTcCTFTEST10/         tpTcCTFTESTTIGHT02/    tpTcTNLC14_2/
> tpTcTNLC6_5/
> 
> and each subdirectory contains a file tp_acc.1. I want to do some processing
> to this file, but asking the user to click each folder and input the file
> name is just too much work for them, how can I just display the files in the
> subdirectories. 


Use the 'glob' module, which simulates '*' and '?' expansion of filenames:

   import glob
   filenames = glob.glob('tpTc*/tp_acc.1')

'filenames' will now contain a list of the files in the subdirectories.

-Steve

-- 
Steve Purcell, Pythangelist
Get testing at http://pyunit.sourceforge.net/
Any opinions expressed herein are my own and not necessarily those of Yahoo


More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4