title: How to iterate through files in a folder using MicroPython?
body: <p>I'm trying to read all files with <code>.asm</code> and <code>.py</code> extensions in an sd card using <strong>MicroPython</strong>.</p>
  <p>I checked the answers in <a href="https://stackoverflow.com/questions/10377998/how-can-i-iterate-over-files-in-a-given-directory">this question</a> but they don't work with MicroPython.</p>
  <p>MicroPython doesn't have <code>glob</code> nor <code>pathlib</code> and when using <code>os</code> library and try this code:</p>
  <pre><code>for file in os.listdir('/sd'):
          filename = os.fsdecode(file)
          if filename.endswith(&quot;.asm&quot;) or filename.endswith(&quot;.py&quot;):
              print(filename)
  </code></pre>
  <p>I get this error <code>'module' object has no attribute 'fsdecode'</code></p>
  <p>How can I get this to work with MicroPython?</p>