How to find file path for specific file for multiple folders
<p>The title doesn't really explain it well, so I'll try to explain it better here. I'm not expecting to be spoon-fed, but I'd like to be pointed in the right direction as to how I would do this.</p>

<p>I have one folder, let's call it A.</p>

<p>A has 100 other folders in, that have the folder name as just a completely random number.</p>

<p>Inside each of these folders, there is a png file, a txt file, and a bsp file.</p>

<p>I have to put the folder directory to the bsp files, into a text file, so that another program can read them (but I think that is irrelevant)</p>

<p>I'd expect to be able to find the file directories for each file, e.g. it would print </p>

<p><code>\A\&lt;random number for the folder&gt;\&lt;bsp file name&gt;
\A\&lt;another random number for another folder&gt;\&lt;the bsp file name for the file in that folder&gt;</code></p>

<p>I'm aware its quite vague, but how would I approach this?</p>

<p>What you require can be achieved with the 'find' command on the shell.</p>

<p>After changing into the main directory with all the subdirectories, to get the relative path, execute:</p>

<pre><code>find -name *.bsp
./1/aa.bsp
./2/bb.bsp
./3/cc.bsp
</code></pre>

<p>And for absolute path, execute:</p>

<pre><code>find -name *.bsp -exec readlink -f {} \;
/home/user/A/1/aa.bsp
/home/user/A/2/bb.bsp
/home/user/A/3/cc.bsp
</code></pre>

<p>You can execute this in python using os.system()</p>

python