[Tutor] List files in directory
EJP
ejp at zomething.com
Sun Aug 15 22:22:26 CEST 2004
"Bernard Lebel" wrote:
>
> Hello,
>
> Anyone has advice on how to collect filenames from a directory?
<snip>
> I want to print only the files contains in the currently visited directory.
This is simple enough that I can help:
import os
path="C:\\somedirectory" # insert the path to the directory of interest here
dirList=os.listdir(path)
for fname in dirList:
print fname
More information about the Tutor
mailing list