Monday, 15 June 2015

python - Indexed list of files in a folder that match a criteria -


I am trying to list all the files in a folder which MySample% i% j.wav < Matches the / code> (where % i should be an integer, % j ), but as a result (I tried glob.glob ('MySample * .wav) ') ):

  ["MySample 117 12.wav", "MySample 011 18.wav", "MySample 13 45.wav"]  

I like some things that want to be indexed by pattern variable% i,% j :

  {(117, 12): " MySample 117 12. Wave ", (11, 18):" MySmall 011 18. Eve ", (13, 45): "Myspace 13 45. Wave"}  

  os, re Samples = {} for F in oslistdir ("."): M = re.match (r "MySample (\ d +) (\ d +) .wav", f) if m: samples [tuple (int (x) X for m.groups ())] = f  

No comments:

Post a Comment