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).
|
* `TENANT_ID`, `CLIENT_ID`, `CLIENT_SECRET` (Fra Microsoft Entra admin center).
|
||||||
* `SITE_URL`: URL til din SharePoint site.
|
* `SITE_URL`: URL til din SharePoint site.
|
||||||
* `DOCUMENT_LIBRARY`: Navnet på dokumentbiblioteket (f.eks. "22 Studies").
|
* `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.
|
* `LOCAL_PATH`: Hvor filerne skal gemmes lokalt.
|
||||||
|
|
||||||
## Anvendelse
|
## Anvendelse
|
||||||
|
|||||||
@@ -3,5 +3,5 @@ CLIENT_ID = "*** INPUT CLIENT ID HERE ***"
|
|||||||
CLIENT_SECRET = "*** INPUT CLIENT SECRET HERE ***"
|
CLIENT_SECRET = "*** INPUT CLIENT SECRET HERE ***"
|
||||||
SITE_URL = "*** INPUT SHAREPOINT SITE URL HERE ***"
|
SITE_URL = "*** INPUT SHAREPOINT SITE URL HERE ***"
|
||||||
DOCUMENT_LIBRARY = "*** INPUT DOCUMENT LIBRARY NAME HERE (e.g. Documents) ***"
|
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 ***"
|
LOCAL_PATH = "*** INPUT LOCAL DESTINATION PATH HERE ***"
|
||||||
|
|||||||
@@ -140,6 +140,10 @@ def main():
|
|||||||
|
|
||||||
folders_to_download = [f.strip() for f in folders_to_download_str.split(',') if f.strip()]
|
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)...")
|
print(f"Connecting via Graph API (with auto-refresh and skip logic)...")
|
||||||
|
|
||||||
report = []
|
report = []
|
||||||
@@ -154,7 +158,11 @@ def main():
|
|||||||
drive_id = get_drive_id(app, site_id, drive_name)
|
drive_id = get_drive_id(app, site_id, drive_name)
|
||||||
|
|
||||||
for folder in folders_to_download:
|
for folder in folders_to_download:
|
||||||
|
if folder == "":
|
||||||
|
print("\nProcessing entire document library (Root)...")
|
||||||
|
else:
|
||||||
print(f"\nProcessing folder: {folder}")
|
print(f"\nProcessing folder: {folder}")
|
||||||
|
|
||||||
local_folder_path = os.path.join(local_path_base, folder)
|
local_folder_path = os.path.join(local_path_base, folder)
|
||||||
download_folder_recursive(app, drive_id, folder, local_folder_path, report)
|
download_folder_recursive(app, drive_id, folder, local_folder_path, report)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user