In ArcGIS Notebooks, I run Python scripts that output data into the Notebook file structure. In the file structure, you have the option to "Select All", but you can only "Delete All."
I suggest that you add a "Download" button near the "Delete" button, so when you select all files, you may download all files vs having to click each file one at a time.
You can zip up a directory using Python, but having a GUI way to do that would be cool.
Until that happens, you could create a code snippet and save it, to add to notebooks where you want this functionality.
import os
import zipfile
def zip_directory(source_dir, output_zip_file):
"""
Zips all files within a given directory into a single ZIP archive.
Args:
source_dir (str): The path to the directory to be zipped.
output_zip_file (str): The name of the output ZIP file.
"""
try:
with zipfile.ZipFile(output_zip_file, 'w', zipfile.ZIP_DEFLATED) as zipf:
for root, _, files in os.walk(source_dir):
for file in files:
file_path = os.path.join(root, file)
# Calculate the relative path within the zip file
arcname = os.path.relpath(file_path, source_dir)
zipf.write(file_path, arcname)
print(f"Successfully created '{output_zip_file}' from '{source_dir}'.")
except Exception as e:
print(f"Error zipping directory: {e}")
# Example usage:
source_directory_to_zip = '/arcgis/home/the_dir_to_zip' # Replace with your directory name
output_zip_archive = "my_archive.zip" # By default writes to your home (arcgis/ directory)
# Run the function to zip up the directory
zip_directory(source_directory_to_zip, output_zip_archive)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.