July 27th, 2005, 08:34 AM
Hello! While making a script to resize my photos, I encountered some problems with the shutil module. I use Python 2.4.1 on Win XP SP 1.
When I use the shutil method copy() to copy one directory to another the python interpreter gives an error that says I have no acces to the 'source' directory. Changing the permissions of the folder with os.chmod() before using shutil.copy() doesn't help either.
I have searched my manual, the PyDocs and the python site but I don't have any clue.
>>> os.chmod('C:\Documents and Settings\Matthias\My Documents\My Pictures\\testfoto',0777) #Write/exe for everyone
>>> shutil.copy('C:\Documents and Settings\Matthias\My Documents\My Pictures\\testfoto','C:\Documents and Settings\Matthias\My Documents\My Pictures\testfoto1')
#copy dir testfoto to dir testfoto1
IOError: [Errno 13] Permission denied: 'C:\\Documents and Settings\\Matthias\\My Documents\\My Pictures\\testfoto'
Is there anyone who knows what I should try?
Thanks in advance
July 27th, 2005, 02:47 PM
At first I thought that you might be falling victim to one of those darn Microsoft fatuities. This one called space-in-folder-name.
That does not seem to be a problem. Your problem is that you cannot copy folders/directories, but must copy individual files. The destination directory has to exist.
July 27th, 2005, 03:46 PM
That was what I tought too.
Well, anyway I have made an iteration method to copy a complete folder file by file, wich works fine.
Thanks for your fast reply!