This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Csaba.Makara
Recipients Csaba.Makara, dstufft, eric.araujo
Date 2014-08-04.07:15:34
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1407136534.84.0.777001072361.issue22132@psf.upfronthosting.co.za>
In-reply-to
Content
If I use the distutils.dir_util.copy_tree to copy the same directory structure multiple times to the same place (even from multiple sources) but I remove and recreate the target_directory before each copy, the following exception accurs:

g:\_Programming>py example.py
Traceback (most recent call last):
  File "E:\Python34\lib\distutils\file_util.py", line 41, in _copy_file_contents

    fdst = open(dst, 'wb')
FileNotFoundError: [Errno 2] No such file or directory: 'c:\\bin\\folder_inside\
\file_inside.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "example.py", line 13, in <module>
    dir_util.copy_tree(source_folder2, target_folder)
  File "E:\Python34\lib\distutils\dir_util.py", line 160, in copy_tree
    verbose=verbose, dry_run=dry_run))
  File "E:\Python34\lib\distutils\dir_util.py", line 164, in copy_tree
    dry_run=dry_run)
  File "E:\Python34\lib\distutils\file_util.py", line 143, in copy_file
    _copy_file_contents(src, dst)
  File "E:\Python34\lib\distutils\file_util.py", line 44, in _copy_file_contents

    "could not create '%s': %s" % (dst, e.strerror))
distutils.errors.DistutilsFileError: could not create 'c:\bin\folder_inside\file
_inside.txt': No such file or directory
_______________________________________________________________

If the target_folder is not deleted, the problem won't appear. 
The problem seems to be the handling of the inner directories. In the second attempt the inner folders are thought to be existing, but they are not.

See the attached script.
History
Date User Action Args
2014-08-04 07:15:34Csaba.Makarasetrecipients: + Csaba.Makara, eric.araujo, dstufft
2014-08-04 07:15:34Csaba.Makarasetmessageid: <1407136534.84.0.777001072361.issue22132@psf.upfronthosting.co.za>
2014-08-04 07:15:34Csaba.Makaralinkissue22132 messages
2014-08-04 07:15:34Csaba.Makaracreate