Thanks for responding<div>When I try glob.glob I receive no errors but nothing prints.</div><div><div><br></div><div>MainFolder=r&quot;E:/Sample/&quot;</div><div>for dir in glob.glob(MainFolder + &#39;01&#39;):</div><div>        print &quot;my selected directories are:&quot;, dir</div>
<div>        for ncfile in glob.glob(&#39;.nc&#39;):</div><div>            print &quot;my selected netcdf files are:&quot;, ncfile</div></div><div><br></div><div>any suggestions? thanks</div><div><br><br><div class="gmail_quote">
On Tue, Aug 30, 2011 at 10:07 AM, Emile van Sebille <span dir="ltr">&lt;<a href="mailto:emile@fenx.com">emile@fenx.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
On 8/29/2011 4:52 PM questions anon said...<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am trying to select particular files within<br>
a particular subdirectory,<br>
</blockquote>
<br></div>
You might find glob a better starting point:<br>
<br>
ActivePython 2.6.6.15 (ActiveState Software Inc.) based on<br>
Python 2.6.6 (r266:84292, Aug 24 2010, 16:01:11) [MSC v.1500 32 bit (Intel)] on win32<br>
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.<br>
&gt;&gt;&gt; import glob<br>
&gt;&gt;&gt; help(glob.glob)<br>
Help on function glob in module glob:<br>
<br>
glob(pathname)<br>
    Return a list of paths matching a pathname pattern.<br>
<br>
    The pattern may contain simple shell-style wildcards a la fnmatch.<br>
<br>
&gt;&gt;&gt; for filename in glob.glob(r&#39;C:\WSG\GL\2011-08\<u></u>*.txt&#39;):<br>
    print filename<br>
...<br>
C:\WSG\GL\2011-08\2011-01-WIP-<u></u>Details.txt<br>
C:\WSG\GL\2011-08\2011-02-WIP-<u></u>Details.txt<br>
C:\WSG\GL\2011-08\2011-03-WIP-<u></u>Details.txt<br>
C:\WSG\GL\2011-08\2011-04-WIP-<u></u>Details.txt<br>
C:\WSG\GL\2011-08\2011-05-WIP-<u></u>Details.txt<br>
C:\WSG\GL\2011-08\2011-06-WIP-<u></u>Details.txt<br>
C:\WSG\GL\2011-08\2011-07 - bankToRec.txt<br>
C:\WSG\GL\2011-08\2011-07 - vsdsToRec.txt<br>
C:\WSG\GL\2011-08\2011-07-WIP-<u></u>Details.txt<br>
C:\WSG\GL\2011-08\5790-00 RECONCILIATION.txt<br>
C:\WSG\GL\2011-08\<u></u>BankRecUtils.txt<br>
C:\WSG\GL\2011-08\<u></u>CapitalizationExamples.txt<br>
C:\WSG\GL\2011-08\DEALLOCATE-<u></u>2011-04.txt<br>
C:\WSG\GL\2011-08\dump glsmf1 data for 2004-2010.txt<br>
C:\WSG\GL\2011-08\MAR DEALLOCATION.txt<br>
C:\WSG\GL\2011-08\Notes.txt<br>
C:\WSG\GL\2011-08\shipping safety net util.txt<br>
C:\WSG\GL\2011-08\UNBILLED WIP.txt<br>
C:\WSG\GL\2011-08\Vacation Accrual - post-bonus-changes.txt<br>
C:\WSG\GL\2011-08\Vacation Accrual - pre-bonus-changes.txt<br>
C:\WSG\GL\2011-08\vacation accrual notes.txt<br>
&gt;&gt;&gt;<br>
<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
I have been able to do both but not together!<br>
When I try to select my files within the dir loop nothing comes up, but<br>
when I leave the files outside the dir loops it selects all the files<br>
not just the ones in the dirs I have selected.<br>
The code I am using is:<br>
<br>
import os<br>
<br>
MainFolder=r&quot;D:/samples/&quot;<br>
<br>
for (path, dirs, files) in os.walk(MainFolder):<br>
     for dir in dirs:<br>
         if dir==&#39;01&#39;:<br>
             print &quot;selected directories are:&quot;,dir<br>
<br>
             for ncfile in dir:<br>
                   if ncfile[-3:]==&#39;.nc&#39;:<br>
                         print &quot;ncfiles are:&quot;, ncfile<br>
<br>
Any feedback will be greatly appreciated!!<br>
<br>
<br></div>
______________________________<u></u>_________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/tutor</a><br>
</blockquote>
<br>
<br>
______________________________<u></u>_________________<br>
Tutor maillist  -  <a href="mailto:Tutor@python.org" target="_blank">Tutor@python.org</a><br>
To unsubscribe or change subscription options:<br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/<u></u>mailman/listinfo/tutor</a><br>
</blockquote></div><br></div>