Using Python, How to copy files in 'temporary internet files' folder in Windows

Posted by pythBegin on Stack Overflow See other posts from Stack Overflow or by pythBegin
Published on 2010-05-19T14:32:32Z Indexed on 2010/05/19 15:30 UTC
Read the original article Hit count: 193

Filed under:
|
|
|

I am using this code to find files recursively in a folder , with size greater than 50000 bytes.

def listall(parent):
    lis=[] 
    for root, dirs, files in os.walk(parent):
         for name in files:
             if os.path.getsize(os.path.join(root,name))>500000:                                
                   lis.append(os.path.join(root,name))
    return lis 

This is working fine. But when I used this on 'temporary internet files' folder in windows, am getting this error.

Traceback (most recent call last):
File "<pyshell#4>", line 1, 
in <module> listall(a) File "<pyshell#2>", 
line 5, in listall if os.path.getsize(os.path.join(root,name))>500000: 
File "C:\Python26\lib\genericpath.py", line 49, in getsize return os.stat(filename).st_size WindowsError: [Error 123] The filename, directory name, or volume label syntax is incorrect: 'C:\\Documents and Settings\\khedarnatha\\Local Settings\\Temporary Internet Files\\Content.IE5\\EDS8C2V7\\??????+1[1].jpg' 

I think this is because windows gives names with special characters in this specific folder... Please help to sort out this issue.

© Stack Overflow or respective owner

Related posts about python

Related posts about path