0

I want to program a small script using python which goes into my google drive folder and copies all the files there to a folder with the current date. So fromDirectory is obviously the directory where my program should copy the files from and todirectory is a directory on a extern hdd. I already check if the paths are correct and I'm sure that they are. Unfortunately a error raised:

Traceback (most recent call last):
  File "C:\Users\Michael\Desktop\test.py", line 13, in <module>
    copy_tree(fromDirectory, toDirectory)
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python37\lib\distutils\dir_util.py", line 124, in copy_tree
    "cannot copy tree '%s': not a directory" % src)
distutils.errors.DistutilsFileError: cannot copy tree 'C:/Users/Michael/Desktop/Google Drive': not a directory

Code:

import time
import sys
import shutil
from distutils.dir_util import copy_tree
import os
from datetime import datetime

today = datetime.now()

fromDirectory = "C:/Users/Micheal/Desktop/Google Drive"
toDirectory = "S:/" + today.strftime('%d%m%Y') 

copy_tree(fromDirectory, toDirectory)

Hope for help!

EDIT: I was stupid:

I wrote my program on PC1 and now tested it on PC2, so I didn't notice that there really was a Google Drive folder on the desktop of PC1 but not on the desktop of PC2 (just a shortcut to the Google Drive folder). For PC2 the correct path is "C:/Users/Michael/Google Drive".

Michael Brown
  • 137
  • 2
  • 13

1 Answers1

0

The problem is probably the ' ' in 'Google Drive', try renaming it to 'Google_Drive' or 'Google-Drive'. You can also try to replace "C:/Users/Micheal/Desktop/Google Drive" with "C:/Users/Micheal/Desktop/'Google Drive'", as that is how it works in bash scripts, but I can't guarantee it'll work in that case

Edit: You can also add a \ before the space, so Google Drive becomes Google\ Drive.

LombardiD
  • 301
  • 1
  • 2
  • 9
  • Thank you for your answer, but unfortunately none of the three options worked. Other ideas? – Michael Brown Aug 29 '20 at 14:41
  • Try removing the space (' ') all together. Change the name of the google drive folder to `Google-Drive` and do the same in your code – LombardiD Aug 29 '20 at 14:46
  • Or even maybe swap out `"C:/Users/Micheal/Desktop/Google Drive"` for `'C:/Users/Micheal/Desktop/"Google Drive"'` - its weird but it just may work – LombardiD Aug 29 '20 at 14:48
  • Yeah, but I've already tested it. (I even swapped to GoogleDrive). The weird thing about all this is that it all works if I replace Google Drive with Testfolder (and creating Testfolder on the Dektop) – Michael Brown Aug 29 '20 at 14:50