[英]How to copy folder and its content into new location in SharePoint Online with python office365 module
I am trying to copy a folder with all its content from one site to another in SharePoint Online.我正在尝试在 SharePoint Online 中将一个文件夹及其所有内容从一个站点复制到另一个站点。 So I created a code that recursively creates the folder structure.
所以我创建了一个递归创建文件夹结构的代码。
What I can't do is to copy the files.我不能做的是复制文件。 For the start I am trying to test the following very simple code which I got from GitHub
首先,我尝试测试从GitHub获得的以下非常简单的代码
url = 'https://company.sharepoint.com/sites/MyTeam'
ctx = ClientContext(url).with_credentials(ClientCredential(client_id, client_secret))
source_folder = ctx.web.get_folder_by_server_relative_url('Shared Documents/from')
target_folder = source_folder.copy_to('Shared Documents/to').get().execute_query()
This code doesn't do anything at all.这段代码根本不做任何事情。
I tried to check the paths and print out the files in the source_folder
and target_folder
.我试图检查路径并打印出
source_folder
和target_folder
中的文件。 It prints out the files in the source_folder
and prints nothing for the target_folder
.它打印出
source_folder
中的文件,并且不为target_folder
打印任何内容。
What am I missing here?我在这里想念什么?
You could try to use sever relatice url like this:您可以尝试像这样使用 server relatice url:
/sites/MyTeam/Shared Documents/from
and /sites/MyTeam/Shared Documents/to
/sites/MyTeam/Shared Documents/from
和/sites/MyTeam/Shared Documents/to
Check if it works.检查它是否有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.