问题描述
我想使用python编写一个小脚本,该脚本进入我的google驱动器文件夹,并将所有文件复制到当前日期的文件夹中。因此,fromDirectory显然是我的程序应该将文件从from和todirectory复制到的目录,是extern hdd上的目录。我已经检查了路径是否正确,并且确定它们是正确的。不幸的是,出现了错误:
RNFetchBlob
.config({
fileCache: true,path: path + '/' + name + '.mp3',})
.fetch('GET',url,{
//some headers ..
})
.then((res) => {
const shareOptions = {
subject: 'Music',title: 'Sound',message: '',url: "file://" + res.path(),};
const shareOptionsSingle = {
title:'ad',social: Share.social.WHATSAPP,type:'audio/mp3'
};
Share.shareSingle(shareOptionsSingle)
.then((res) => { console.log(res) })
.catch((err) => { err && console.log(err); });
Share.open(shareOptions)
.then((res) => {
console.log("yolo")
console.log(res)
})
.catch((err) => console.log(err))
})
代码:
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
希望获得帮助!
编辑: 我很愚蠢:
我在PC1上编写了程序,现在在PC2上进行了测试,所以我没有注意到PC1桌面上确实有一个Google Drive文件夹,但PC2桌面上没有(只是Google Drive的快捷方式)夹)。对于PC2,正确的路径是“ C:/ Users / Michael / Google Drive”。
解决方法
问题可能出在“ Google云端硬盘”中的' '
,请尝试将其重命名为“ Google_Drive”或“ Google-Drive”。
您也可以尝试将"C:/Users/Micheal/Desktop/Google Drive"
替换为"C:/Users/Micheal/Desktop/'Google Drive'"
,因为这在bash脚本中是这样的,但是我不能保证在这种情况下它可以工作
编辑:
您还可以在空格前添加\
,这样Google Drive
会变成Google\ Drive
。