Re: ls files --> list packer

2006-02-27 Thread Magnus Lycka
kpp9c wrote: > that is nice but the little further wrinkle, which i have no idea > how to do, would be to have the contents of each directory packed into > a different list since you have no idea before hand how many lists > you will need (how many subdirs you will enounter) ... well that

Re: ls files --> list packer

2006-02-27 Thread Scott David Daniels
kpp9c wrote: > Thank you... i was looking in the wrong place cause all i found was > this relatively useless doc: > http://docs.python.org/lib/module-os.html > which says almost nothing. > In one of its subsections, cleverly named "Files and Directories", I see a nice description of listdir.

Re: ls files --> list packer

2006-02-27 Thread kpp9c
nice! two little lines that do a boatload of work! hee hee pth = '/Users/kpp9c/snd/01' samples = [os.path.join(pth, f) for f in os.listdir(pth) if f.endswith('.aif')] thank you Kent! (and Jeremy and Magnus and Singletoned and I V ... and john boy and mary ellen .. ) -- http://mail.pyt

Re: ls files --> list packer

2006-02-26 Thread kpp9c
Thank you... i was looking in the wrong place cause all i found was this relatively useless doc: http://docs.python.org/lib/module-os.html which says almost nothing. -- http://mail.python.org/mailman/listinfo/python-list

Re: ls files --> list packer

2006-02-26 Thread Kent Johnson
kpp9c wrote: > os.listdir works great ... just one problem, it packs the filenames > only into a list... i need the full path and seach as i might i se NO > documentation on python.org for os.listdir() Docs for os.listdir() are here: http://docs.python.org/lib/os-file-dir.html When all else fails

Re: ls files --> list packer

2006-02-26 Thread kpp9c
os.listdir works great ... just one problem, it packs the filenames only into a list... i need the full path and seach as i might i se NO documentation on python.org for os.listdir() how do i either grab the full path or append it later ... -- http://mail.python.org/mailman/listinfo/python-list

Re: ls files --> list packer

2006-02-24 Thread kpp9c
that is nice but the little further wrinkle, which i have no idea how to do, would be to have the contents of each directory packed into a different list since you have no idea before hand how many lists you will need (how many subdirs you will enounter) ... well that is where the hairy pa

Re: ls files --> list packer

2006-02-24 Thread Magnus Lycka
kpp9c wrote: > that other sillyness i mentioned is not strickly required ... just > dreaming but i know involves some kind of os walk type thing prolly ... os.walk isn't exactly rocket science... Something similar to this? >>> import os >>> for dir, dirs, files in os.walk('.'): ... txt_fil

Re: ls files --> list packer

2006-02-24 Thread Singletoned
Try using The Path module: http://www.jorendorff.com/articles/python/path/. I wrote a little script to traverse a directory structure which you could use. (You just pass a function to it and it runs it on each file in the directory. You want it to run on each directory instead, so I've changed i

Re: ls files --> list packer

2006-02-24 Thread Jeremy Sanders
I V wrote: > snd_filelist = [f for f in os.listdir('/snd/Public/') if > f.endswith('.aiff')] Or even from glob import glob snd_filelist = glob('/snd/Public/*.aiff') Jeremy -- Jeremy Sanders http://www.jeremysanders.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: ls files --> list packer

2006-02-24 Thread kpp9c
gosh i could even use other string methods like startswith to take all the files in a given directory which i have organized with a prefix and have them stuffed in different lists ... i think ... snd_filelist = [f for f in os.listdir('/Users/foo/snd') if f.endswith('.aif') & f.startswith('r')] \

Re: ls files --> list packer

2006-02-24 Thread kpp9c
cool i just tried: >>> import os >>>snd_filelist = [f for f in os.listdir('/Users/foo/snd') if >>>f.endswith('.aif')] and it worked! and will take a huge bite out of my big script ... which i make by doing an ls in the terminal and editing (boo hoo) one one lc and one import! cool.. that oth

Re: ls files --> list packer

2006-02-23 Thread I V
kpp9c wrote: > Namely i have organized a bunch of folders that have soundfiles in them > and would like Python to slurp up all the .aif/.aiff (or .wav whatever) > files in a given set of directories. My friend hacked up this is perl: > > $files = `ls /snd/Public/*.aiff`; You could use posix.popen

Re: ls files --> list packer

2006-02-23 Thread kpp9c
and one example of a slightly fancier version would be a variation that looks recursively into subdirectories and makes separate lists for each subdirectory encountered. so if i had a directory called "~/snd/" and in "~/snd/" i had: "~/snd/one/" "~/snd/two/" "~/snd/three/" each with soundfiles

ls files --> list packer

2006-02-23 Thread kpp9c
I would like to use the power of Python to build some list structures for me. Namely i have organized a bunch of folders that have soundfiles in them and would like Python to slurp up all the .aif/.aiff (or .wav whatever) files in a given set of directories. My friend hacked up this is perl: $fil