<div class="gmail_quote">On 25 September 2012 00:33, Gregory Lund <span dir="ltr"><<a href="mailto:gnj091405@gmail.com" target="_blank">gnj091405@gmail.com</a>></span> wrote: <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">z.extractall(outDir)</div><div class="im">
<br>
zipContents = z.namelist()<br>
print zipContents<br>
</div>z.close()<br>
<div class="im"><br>
for item in zipContents:<br>
    if item.endswith('.zip'):<br>
</div>        x = zipfile.ZipFile(item,'r')<br>
        x.extractall()<br>
        x.close()<br><div class="im"><br>
</div><div class="im">Traceback (most recent call last):<br>
</div>  File "D:/D_Drive_Documents/Scripts/Unzip_a_zip_of_zips/Scripts/unzip_a_zip_of_zips_rewrite_shortest_of_the_shorts2.py",<br>
line 18, in <module><br>
    x = zipfile.ZipFile(item,'r')<br>
  File "C:\Python26\ArcGIS10.0\lib\zipfile.py", line 683, in __init__<br>
<div class="im">    self.fp = open(file, modeDict[mode])<br>
</div>IOError: [Errno 2] No such file or directory: 'Lab_2/aforker/aforker_Lab2.zip'<br>
>>><br>
<br>
Near as I can tell, I got rid of the permissions error, the ZipFile<br>
error with the missing capital 'F'<br>
Now I need to 'get into' the non zipped folder of each student and<br>
unzip any and all zips that are inside of it.<br></blockquote><div><br></div><div>The error message says 'No such file or directory'. That means that when Python tries to open a file with the name you gave it can't find a file that has that name. In this case I suspect the problem is that you need to give the full path to each file i.e. instead of</div>
<div>  'Lab_2/aforker/aforker_Lab2.zip'</div><div>you need to give</div><div> 'D:\D_Drive_Documents\Student_Work_Sample_usecopy1\Lab_2\aforker\aforker_Lab2.zip'</div><div><br></div><div>You can create the full path with:</div>
<div><br></div><div>import os.path   # Put this at the top of your file</div><div><br></div><div>for item in zipContents:</div><div class="im">  if item.endswith('.zip'):<br></div><div class="im">      # Combine the base folder name with the subpath to the zip file</div>
<div class="im">      fullpath = os.path.join(outDir, item)</div>      x = zipfile.ZipFile(fullpath,'r')</div><div class="gmail_quote"><br></div><div class="gmail_quote">I just googled to find you a page explaining absolute paths and, by chance, came up with this from the ArcGIS documentation:</div>
<div class="gmail_quote"><a href="http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Pathnames%20explained%3A%20Absolute%2C%20relative%2C%20UNC%2C%20and%20URL">http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=Pathnames%20explained%3A%20Absolute%2C%20relative%2C%20UNC%2C%20and%20URL</a></div>
<div class="gmail_quote"><br></div><div class="gmail_quote">Oscar</div>