-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathcopy_file.py
More file actions
19 lines (16 loc) · 716 Bytes
/
Copy pathcopy_file.py
File metadata and controls
19 lines (16 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""
Demonstrates how to copy a file within a site
"""
from office365.sharepoint.client_context import ClientContext
from tests import test_client_id, test_password, test_site_url, test_tenant, test_username
ctx = ClientContext(test_site_url).with_username_and_password(
tenant=test_tenant,
client_id=test_client_id,
username=test_username,
password=test_password,
)
file_from = ctx.web.get_file_by_server_relative_url("Shared Documents/Financial Sample.xlsx")
folder_to = ctx.web.get_folder_by_server_relative_url("Shared Documents/archive")
# folder_to = "Shared Documents/archive/2002/02"
file_to = file_from.copyto(folder_to, True).execute_query()
print(f"{file_from} copied into '{file_to}'")