<br><br><div class="gmail_quote">On 24 September 2012 03:00, Gregory Lund <span dir="ltr"><<a href="mailto:gnj091405@gmail.com" target="_blank">gnj091405@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">>>> > You're trying to open the directory as if it were a zipfile. You should<br>
>>> > pass in the path to a zipfile not to a folder.<br>
>>><br>
>>> Agreed, but how do I do that "pass in the path to a zipfile'?<br>
>>> Using an if statement I presume?<br>
>>><br>
>>> > ><br>
>>><br>
>>> > > I guess my first issue is to resolve the 'Permission denied' problem.<br>
>>> > > And, I know I need an 'if' statement, somehow...<br>
>>> ><br>
>>> Yes, the permission denied problem seems to be the first real<br>
>>> obstacle, but I can't figure it out.<br>
>>> I tried searching online but everything I found to try, didn't work.<br>
>><br>
>><br>
>> The permission error is because you are trying to open a folder as if it<br>
>> were a file. The operating system does not give you permission to do this<br>
>> because it is a nonsensical operation.<br>
>><br>
>>> > Remove the folder paths from the list of paths.<br>
>>><br>
>>> How can I remove the folder paths from the list of paths?<br>
>><br>
>><br>
>> You can do it with a list comprehension:<br>
>><br>
>> import os.path<br>
>> paths = [p for p in paths if os.path.isdir(p)]<br>
><br>
><br>
> Sorry that should be (note the 'not'):<br>
> paths = [p for p in paths if not os.path.isdir(p)]<br>
><br>
</div>Ok, but where do I put that?<br>
Sorry Oscar, I don't know where to put it, nor do I know how to use<br>
'paths' once I do that.<br>
<br>
I was trying this prior to getting your email about paths...(I put<br>
this after z.close()<br>
<br>
for item in zipContents:<br>
    if item(-4) == ('.zip'):<br></blockquote><div><br></div><div>That should be:</div><div>if item[-4:] == '.zip'</div><div><br></div><div>but a better way to do that is:</div><div>if item.endswith('.zip')</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">        x = zipfile.Zipfile(item,'r')<br>
        x.extractall()<br>
        x.close()<br>
<br>
but, I kept getting a "TypeError: 'str' object is not callable" error.<br>
<br>
then I tried<br>
<br>
for item in zipContents:<br>
    if item.lower() .endswith(".zip"):<br></blockquote><div><br></div><div>Ok that's better.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

        item.extractall()<br>
        item.close()<br>
<br>
but got a "    item.extractall()<br>
AttributeError: 'str' object has no attribute 'extractall'" error<br></blockquote><div><br></div><div>item is a string object. You need to use that string to create a ZipFile object and then call extractall() on the ZipFile object (the way you did in your original post in this thread).</div>
<div><br></div><div>Oscar</div></div>