Understøt download af hele biblioteket hvis FOLDERS_TO_DOWNLOAD er tom
This commit is contained in:
@@ -26,7 +26,7 @@ Dette script gør det muligt at downloade specifikke mapper fra et SharePoint do
|
||||
* `TENANT_ID`, `CLIENT_ID`, `CLIENT_SECRET` (Fra Microsoft Entra admin center).
|
||||
* `SITE_URL`: URL til din SharePoint site.
|
||||
* `DOCUMENT_LIBRARY`: Navnet på dokumentbiblioteket (f.eks. "22 Studies").
|
||||
* `FOLDERS_TO_DOWNLOAD`: Liste over mapper adskilt af komma.
|
||||
* `FOLDERS_TO_DOWNLOAD`: Liste over mapper adskilt af komma. Hvis denne efterlades tom, downloades hele biblioteket.
|
||||
* `LOCAL_PATH`: Hvor filerne skal gemmes lokalt.
|
||||
|
||||
## Anvendelse
|
||||
|
||||
@@ -3,5 +3,5 @@ CLIENT_ID = "*** INPUT CLIENT ID HERE ***"
|
||||
CLIENT_SECRET = "*** INPUT CLIENT SECRET HERE ***"
|
||||
SITE_URL = "*** INPUT SHAREPOINT SITE URL HERE ***"
|
||||
DOCUMENT_LIBRARY = "*** INPUT DOCUMENT LIBRARY NAME HERE (e.g. Documents) ***"
|
||||
FOLDERS_TO_DOWNLOAD = "*** INPUT FOLDERS TO DOWNLOAD (Comma separated) ***"
|
||||
FOLDERS_TO_DOWNLOAD = "*** INPUT FOLDERS TO DOWNLOAD (Comma separated). LEAVE EMPTY TO DOWNLOAD ENTIRE LIBRARY ***"
|
||||
LOCAL_PATH = "*** INPUT LOCAL DESTINATION PATH HERE ***"
|
||||
|
||||
@@ -139,6 +139,10 @@ def main():
|
||||
local_path_base = config.get('LOCAL_PATH', '').replace('\\', os.sep)
|
||||
|
||||
folders_to_download = [f.strip() for f in folders_to_download_str.split(',') if f.strip()]
|
||||
|
||||
# If no folders specified, download everything from root
|
||||
if not folders_to_download:
|
||||
folders_to_download = [""] # Empty string represents root folder
|
||||
|
||||
print(f"Connecting via Graph API (with auto-refresh and skip logic)...")
|
||||
|
||||
@@ -154,7 +158,11 @@ def main():
|
||||
drive_id = get_drive_id(app, site_id, drive_name)
|
||||
|
||||
for folder in folders_to_download:
|
||||
print(f"\nProcessing folder: {folder}")
|
||||
if folder == "":
|
||||
print("\nProcessing entire document library (Root)...")
|
||||
else:
|
||||
print(f"\nProcessing folder: {folder}")
|
||||
|
||||
local_folder_path = os.path.join(local_path_base, folder)
|
||||
download_folder_recursive(app, drive_id, folder, local_folder_path, report)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user