Skip to content

Instantly share code, notes, and snippets.

@nuriozbey
Last active September 6, 2022 11:00
Show Gist options
  • Select an option

  • Save nuriozbey/fd68495a58f08961cd0b82fabad26c2b to your computer and use it in GitHub Desktop.

Select an option

Save nuriozbey/fd68495a58f08961cd0b82fabad26c2b to your computer and use it in GitHub Desktop.
"""
Usage:
folder_url = "/teams/<channel>/Shared Documents/General/DummyFolder"
list_files(ctx = ctx, relative_url = folder_url)
"""
def list_files(ctx,relative_url):
libraryRoot = ctx.web.get_folder_by_server_relative_path(relative_url)
ctx.load(libraryRoot)
ctx.execute_query()
files = libraryRoot.files
ctx.load(files)
ctx.execute_query()
url_list = []
for file in files:
print("File name: {0}".format(file.properties["ServerRelativeUrl"]))
url_list.append(file.properties["ServerRelativeUrl"])
return url_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment