#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Location
    Gent, Belgium
    Posts
    19
    Rep Power
    0

    Question shutil.copy() problem


    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.

    For example:
    Code:
     >>> 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'
    I have searched my manual, the PyDocs and the python site but I don't have any clue.
    Is there anyone who knows what I should try?
    Thanks in advance

    J0ker_
  2. #2
  3. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    620
    Rep Power
    65

    Smile


    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.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Location
    Gent, Belgium
    Posts
    19
    Rep Power
    0
    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 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!

IMN logo majestic logo threadwatch logo seochat tools logo