Debugging & possible causes of distutils.dir_util.copy_tree() doesn't exist or not a regular file

301 views Asked by At

I have some simple code to import a csv file of Windows File Paths e.g."C:/Folder/SubFolder/folder1" to copy the contents and any subfolders to a new directory.

When I run the code I get about 1/3 of my sample returning doesn't exist or not a regular file while the other are copied successfully.

The files that are causing problems are either .docx or .pdf but equally as many were copied over successfully.

What could be causing this issue on a local Windows 10 machine and how do I debug it further?

for Submission in FilePaths.itertuples():
    Create the Path
    FolderName = Submission.Group+"-"+Submission.ID+"-"+Submission.FirstName+Submission.Surname
    DestinationPath =DestinationBasePath + Submission.Category+"\\"+ Submission.Value+"\\"+FolderName
    #Copy the source folder tree and contents to the destination 
    try:
        copy_tree(Submission.FullFilePath, DestinationPath,verbose=1)
    except Exception as Ex:
    print(Ex)
    os.listdir(Submission.FullFilePath)
1

There are 1 answers

0
mobcdi On

I suspect it was connected to syncing or file locking issues which prevented the files from being copied.