title: script for auto opening directories (mac os x) and creating m3u playlists
body: <p>Imagine that you have some directories containing both <code>mp3</code> files and sub-directories, also containing <code>mp3</code> files, like:</p>
  
  <pre><code>/music/band1/
  /music/band2/
  /music/band2/dir1/
  /music/band2/dir2/
  /music/band3/dir1/
  /music/band3/dir2/
  /music/band4/
  ...
  </code></pre>
  
  <p>I would like to create a <code>.m3u</code> file in every directory containing <code>mp3</code> files - so for example:</p>
  
  <pre><code>/music/band1/band1.m3u
  /music/band2/band2.m3u
  /music/band2/dir1/dir1.m3u
  /music/band2/dir2/dir2.m3u
  /music/band3/dir1/dir1.m3u
  /music/band3/dir2/dir2.m3u
  /music/band4/band4.m3u
  </code></pre>
  
  <p>The name of <code>.m3u</code> file will be the directory name in which the <code>.m3u</code> is created. (This is just an example directory structure.)</p>
  
  <p>I hope it is clear :)</p>
  
  <p>So far I have this to generate <code>m3u</code> files from <code>*.mp3</code> files, but only in the actual directory, and name it by directory.</p>
  
  <pre><code>#!/bin/bash\
  ls | grep -i mp3 &gt; filelist.txt
  mv filelist.txt filelist.m3u
  FOLDERNAME=${PWD##*/}
  echo $FOLDERNAME
  mv filelist.m3u $FOLDERNAME.m3u
  </code></pre>
  
  <p>What should be added to have it look recursively into every subdirectory of <code>/music</code>, and if there is another sub-sub directory, also look there? Then, execute the <code>m3u</code>-making script in each sub-directory?</p>
  
  <p>Thank you for your help! :)</p>