title: Grab part of filename with Python
body: <p>Newbie here.</p>
  
  <p>I've just been working with Python/coding for a few days, but I want to create a script that grabs parts of filenames corresponding to a certain pattern, and outputs it to a textfile.</p>
  
  <p>So in my case, let's say I have four .pdf like this:</p>
  
  <pre><code>aaa_ID_8423.pdf
  bbbb_ID_8852.pdf
  ccccc_ID_7413.pdf
  dddddd_ID_4421.pdf
  
  (Note that they are of variable length.)
  </code></pre>
  
  <p>I want the script to go through these filenames, grab the string after "ID_" and before the filename extension.</p>
  
  <p>Can you point me in the direction to which Python modules and possibly guides that could assist me?</p>