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>/<directory> 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' folder contained in the /examples/getting-started folder.
- On the File menu, select New / Terminal
- Navigate to the directory above the folder you wish to delete.
Terminal Tip To do this you use theTo demonstrate, I will delete folder called asdf in my
cdcommand (change directory).
examples/getting-started/folder. So I used the following commands to navigate to the right spot.
- I then used the
lscommand to verify that the folder I was looking to delete was in that directory.
Terminal Tip Each of the green lines is a command prompt in the terminal. You will see the first command changed my directory to the /examples/getting-started directory. The second command ls listed the contents of that directory. This listing is on the third line shown above. When the terminal lists the contents, you will see that folders are listed in blue.The asdf folder will be deleted.
- Now is a good time to be sure you want to delete this folder.
- I now use the
rm -rf asdfcommand. This 'removes' (
rm) the specified file or folder 'asdf'.
-rmeans recursively which is necessary if you are deleting a folder and its contents
-fmeans force which means you won't get asked about every file/folder below the directory you are trying to delete.
- To verify you've deleted the folder, you can run
lsagain. It should be gone.
The folder will disappear from the navigation panel on the left shortly.