Bulk Downloads from Jupyter

Jupyter notebooks are great, however the interface for file handling has its issues. One issue is that files have to be downloaded individually, there is no bulk download option. Fortunately we can easily work around this using magic commands.

Illustration demonstrating how selecting multiple files prevents download in Jupyter
Note how Jupyter does not allow download of multiple selected files

Suppose that you have just generated a large number of files you wish to download. Navigate to the folder above the one which contains your target data. Create a new workbook and paste one of the following magic commands into its first cell.

To create a zipped file:


%%bash
zip -r ZipFile.zip FolderToBeZipped

To create a zipped tarball:


%%bash
tar -czf TarFile.tar.gz FolderToBeZipped

Run the cell with shift-enter. Now return to the folder containing your your new workbook and you will find a file containing all your data for easy download.

Another option you may wish to look at if you frequently need to download multiple files is the project at https://github.com/data-8/nbzip

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.