ls files --> list packer

kpp9c kp8 at mac.com
Fri Feb 24 02:23:12 EST 2006


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:

$files = `ls /snd/Public/*.aiff`;

@snd_filelist = split('\n',$files);

$i = 0;
while ($file = @snd_filelist[$i]) {
   print "file $i = @snd_filelist[$i]\n";
   $i++;
}


The only catch with the above code (besides its hideousness hee hee) is
if you have a directory w/i the structure, but in general it works and
with this i can just put gobs of files into separate dirs pack them
into a list and then send them to my script that scrambles them and
plays them.

I would like something similar, that works with python that is more
elegant and maybe even more robust.

but i am failing miserably and my perl friends mock me.

cheers,
kp8




More information about the Python-list mailing list