I have a list of a part of a filename, for each one I want to go through the files in a directory that matches that part and return the filename
<p>So, let's say I have a directory with a bunch of filenames. 
for example:</p>

<p>Scalar Product or Dot Product (Hindi)-fodZTqRhC24.m4a<br>
AP Physics C - Dot Product-Wvhn_lVPiw0.m4a<br>
An Introduction to the Dot Product-X5DifJW0zek.m4a   </p>

<p>Now let's say I have a list, of only the keys, which are at the end of the file names:</p>

<p><code>['fodZTqRhC24', 'Wvhn_lVPiw0, 'X5DifJW0zek']</code></p>

<p>How can I iterate through my list to go into that directory and search for a file name containing that key, and then return me the filename? </p>

<p>Any help is greatly appreciated!</p>

<p>Here is an example: </p>

<p>ls: list of files in a given directory</p>

<p>names: list of strings to search for</p>

<pre><code>import os
ls=os.listdir("/any/folder")
n=['Py', 'sql']
for file in ls:
   for name in names:
     if name in file:
       print(file)
</code></pre>

<p>Results :</p>

<pre><code>.PyCharm50
.mysql_history
zabbix2.sql
.mysql
PycharmProjects
zabbix.sql
</code></pre>

python