cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Get Started Discussions
Start your journey with Databricks by joining discussions on getting started guides, tutorials, and introductory topics. Connect with beginners and experts alike to kickstart your Databricks experience.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Move multiple notebooks at the same time (programmatically)

hbs59
New Contributor III

If I want to move multiple (hundreds of) notebooks at the same time from one folder to another, what is the best way to do that? Other than going to each individual notebook and clicking "Move".

Is there a way to programmatically move notebooks? Like automatically move notebooks to an Archive folder based on last edit date, etc.

1 ACCEPTED SOLUTION

Accepted Solutions

Walter_C
Databricks Employee
Databricks Employee

The best way to move multiple notebooks at the same time from one folder to another is by using the Databricks workspace API to export and then import the notebooks into the new folder. This can be done from the UI at the top of the screen near to the Share option, on the 3 vertical dots you can select export option, this will generate a file with all the notebooks and folders on the page, then you can import them in the desired folder.

To do it programmatically you can refer to KB: https://kb.databricks.com/notebooks-internal/1333098-how-to-migrate-shared-folders-and-the-notebooks

View solution in original post

3 REPLIES 3

Walter_C
Databricks Employee
Databricks Employee

The best way to move multiple notebooks at the same time from one folder to another is by using the Databricks workspace API to export and then import the notebooks into the new folder. This can be done from the UI at the top of the screen near to the Share option, on the 3 vertical dots you can select export option, this will generate a file with all the notebooks and folders on the page, then you can import them in the desired folder.

To do it programmatically you can refer to KB: https://kb.databricks.com/notebooks-internal/1333098-how-to-migrate-shared-folders-and-the-notebooks

hbs59
New Contributor III

Hi, thank you for your response. The link goes to HelpJuice, which I do not have access to. Do you know of an alternative resource/way to view that/etc.?

Walter_C
Databricks Employee
Databricks Employee

You should be redirected to the KB page, but this is the information contained:

Problem

How to migrate Shared folders and the notebooks

Cause

Shared notebooks are not migrated into new workspace by default

Solution

Please find the script to migrate the Shared folder data.

import sys
import os
import subprocess
from subprocess import call, check_output


EXPORT_PROFILE = "primary"
IMPORT_PROFILE = "secondary"


# Get a list of all users
# Export sandboxed environment(folders, notebooks) for each user and import into new workspace.
#Libraries are not included with these APIs / commands.
#print("Trying to migrate workspace for user ".decode() + user)
print ("Trying to migrate workspace for Shared folders ")
export_exit_status = call("databricks workspace export_dir /Shared/" + " ./" + " --profile " + EXPORT_PROFILE, shell = True)
import_exit_status = call("databricks workspace import_dir ./Shared/ /Shared/" + " --profile " + IMPORT_PROFILE, shell=True)
print ("All done")

 

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group