get directory and file names

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Jul 31 16:29:05 CEST 2007


On Tue, 31 Jul 2007 07:23:06 -0700, Alchemist wrote:

> I am working with Python 2.5 on Windows XP (SP2).
> 
> How can I traverse a folder, loop through a list of files and get
> their file name and extension in an elegant, pythonic way?

Take a look at the `os` and the `os.path` modules.  In particular
`os.listdir()`, `os.path.isfile()` and `os.path.splitext()`.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list