[Tutor] Reading directory
Ming Xue
mjxny at hotmail.com
Thu Jan 22 10:59:19 EST 2004
>My question is sorta difficult to explain so bear with me. I need to read a
>directory and select distinct files which are distinct before a certain
>point. Similiar to SQL select distinct. So if i had a directory filled
>with:
>
>family_01.jpg
>family_02.jpg
>family_03.jpg
>family_03.jpg
>
>test_01.jpg
>test_02.jpg
>
>It would optimilly select just.
>family
>test
You can use glob to just read "family" or "test" if they are distinct term.
family_list=glob.glob("path\*family*.jpg")
test_list=glog.glob("path\*test*.jpg")
>Or the whole file name and then filter everything past the _.
>I hope I explained this clearly enough. I need this because I'm making an
>online photo album for my family and want to minimize recoding html by
>having the links to each section dynamincally generated. I am using Linux.
>
>Thanks a lot!!!
>
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
_________________________________________________________________
Check out the new MSN 9 Dial-up fast & reliable Internet access with prime
features! http://join.msn.com/?pgmarket=en-us&page=dialup/home&ST=1
More information about the Tutor
mailing list