-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d3c06f
commit 55f2e9d
Showing
2 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import os | ||
import shutil | ||
|
||
def delete_folders(folder_path, folders_to_delete): | ||
""" | ||
Deletes specified folders within a directory. | ||
:param folder_path: Path to the directory where folders are to be deleted. | ||
:param folders_to_delete: List of folder names to delete. | ||
""" | ||
for root, dirs, files in os.walk(folder_path, topdown=True): | ||
for folder in dirs: | ||
if folder in folders_to_delete: | ||
folder_to_delete = os.path.join(root, folder) | ||
print(f"Deleting folder: {folder_to_delete}") | ||
try: | ||
shutil.rmtree(folder_to_delete) | ||
print(f"Folder '{folder}' deleted successfully.") | ||
except OSError as e: | ||
print(f"Error: {e.strerror}") | ||
|
||
# List of folders to delete | ||
folders_to_delete = ['__pycache__', '.pytest_cache','DOWNLOADED_SPECFILES','DOWNLOADED_TXT'] | ||
|
||
# Path to the directory containing the folders to delete | ||
directory_path = '.' | ||
# Call the function to delete folders | ||
delete_folders(directory_path, folders_to_delete) |