简体   繁体   English

如何将文件夹及其内容复制到 SharePoint 中的新位置 python office365 模块在线

[英]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_foldertarget_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.

相关问题 如何使用工作或学校帐户将 SharePoint Online (Office365) Excel 文件读取到 Python 特别是 pandas? - How to read SharePoint Online (Office365) Excel files into Python specifically pandas with Work or School Account? 如何使用工作或学校帐户在 Python 中阅读 SharePoint Online (Office365) Excel 文件? - How to read SharePoint Online (Office365) Excel files in Python with Work or School Account? 使用 Python 访问 Office365 Sharepoint REST 端点(Python 的 Office365 Sharepoint REST 客户端) - Accessing Office365 Sharepoint REST EndPoints using Python (Office365 Sharepoint REST client for Python) Using Python to access Excel File on Sharepoint using Office365 Python Module - Using Python to access Excel File on Sharepoint using Office365 Python Module 通过 Python office365 API 下载 Sharepoint Docx 文件 - Download Sharepoint Docx file via Python office365 API 通过 Python 单点登录访问 Office365 SharePoint - Access Office365 SharePoint with Single Sign-On via Python 未找到模块错误:未找到 office365 - Module Not found error: office365 not found Python:如何将电子邮件文本正文传递给Office365电子邮件 - Python: How to pass email text body to Office365 Email 如何在 Sharepoint 的列表中上传多个项目在线使用 python office 365 rest - How to upload multiple items in a list in Sharepoint Online using python office 365 rest 在sharepoint office365 REST Python 客户端上传不同大小的文件 - Uploading files of different sizes on sharepoint office365 REST Python Client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM