Created
August 20, 2021 08:01
-
-
Save hyunjong-lee/e0f97aa0e4c353c65c31b596765ee641 to your computer and use it in GitHub Desktop.
List directories and files using Office365-REST-Python-Client library
@JavierMedel Can you give me the result of the following code?
expand_res = doc_lib.items.select(["FileSystemObjectType"]).expand(["File", "Folder"])
dir(expand_res)
The library contains exactly same code as mine as a example.
just add
for file in folder.files:
print(file.name)
def enum_folder(parent_folder, action):
"""
:type parent_folder: Folder
:type action: (Folder)-> None
"""
parent_folder.expand(["Folders", "Files"]).get().execute_query()
action(parent_folder)
for folder in parent_folder.folders:
enum_folder(folder, action)
for file in folder.files:
print(file.name)
@anjanesh Great, Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting the next error. Do you know if something change in the library?
Cell In[64], line 2
1 doc_lib = ctx.web.lists.get_by_title("Documents")
----> 2 items = doc_lib.items.select(["FileSystemObjectType"]).expand(["File", "Folder"]).get().execute_query()
AttributeError: 'ListItemCollection' object has no attribute 'get'