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".
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 caseEdit: You can also add a
\
before the space, soGoogle Drive
becomesGoogle\ Drive
.