Template request | Bug report | Generate Data Product
Tags: #python #shutil #delete #folder #file #directory
Author: Florent Ravenel
Description: This notebook will show how to delete an entire directory tree using the shutil library.
Shutil module in Python provides many functions of high-level operations on files and collections of files. It comes under Python’s standard utility modules. This module helps in automating the process of copying and removal of files and directories.
shutil.rmtree()
is used to delete an entire directory tree, path must point to a directory (but not a symbolic link to a directory).
References:
import shutil
folder_path
: path of the folder to be removed
folder_path = "./my_folder"
shutil.rmtree(folder_path)
print(f"Folder {folder_path} deleted.")