JupyterLab notebooks have a safety feature which prevents you from deleting a folder if it is not empty. You may have hit an error stating:
"Delete Failed Directory /home/jovyan/<folder> not empty"
While thoughtful in wanting to protect us, this can be a major hassle if you have lots of subfolders or files in this folder. The following instructions will describe how to use the command line to delete a folder.
In the following example, we will delete the 'asdf' directory.
- On the File menu, select New -> Terminal.
- Navigate to the directory above the folder you wish to delete using the
cd
command. In this case, the folder we want to delete is in our home directory, so changing directories is not necessary. - Use the
ls
command to verify that the folder we are trying to delete is in that directory.
Terminal Tip The green line is a command prompt in the terminal and the text in parentheses, earthai, is the name of the current virtual environment. Thels
command lists the contents of the current directory. When the terminal lists the contents, you will see that folders are shown in blue. - Use the
rm -rf asdf
command. This removes the specified file or folder.-r
means recursively which is necessary if you are deleting a folder and its contents.-f
means force which means you won't get asked about every file/folder below the directory you are trying to delete. - To verify the folder is deleted, you can run
ls
again. - The folder will disappear from the navigation panel on the left shortly.
Comments
1 comment
Signed up just to say thank you! Simple solution, saved me so much time
Please sign in to leave a comment.