I need to download all files from sharepoint in a group of subfolders, but I'm struggling to get the list of files to use the download Method.
I'm using the python library Office365-REST-Python-Client, specifically the enum_files_and_folders.py example.
The problem is my document library is too large. Then a want to enum only files in a specific subfolder.
My sharepoint structure is something like this:
https://mysite/shared documents/General/.../sheets/year/month
I want to download all xlsx files in sheets folder and subfolders, without transversing all document library structure.
Does anyone know a filter option ?
My current code is something like this:
doc_lib = contexto.web.get_folder_by_server_relative_url(relative_url)
items = doc_lib.items.select(["FileSystemObjectType"]).expand(["File", "Folder"]).get().execute_query()
arquivos_fluxo =[]
for item in items: # type: ListItem
if item.file_system_object_type != FileSystemObjectType.Folder:
if "myfiles.xlsx" in item.file.serverRelativeUrl:
print("File url: {0}".format(item.file.serverRelativeUrl))
arquivos_fluxo.append(item.file.serverRelativeUrl)