Python Tutorials

Delete Multiple Folders With Python in One Click

Hello Guys,

In this Python Tutorial, We are going to learn how to delete multiple folders in one click

With No Delay Let’s Get Started.

First Create Python File Somewhere in your Laptop.

Now Open the Python file in Editor Mode. Start writing this code

Don’t forget that we have created multiple folders with the help of the previous Python tutorial. Now in this, tutorial We are deleting the multiple folders that we created.

import os 
	

directory = "Downloads"

parent = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"

path = os.path.join(parent, directory) 
	
os.rmdir(path)




directory = "England"
	
parent = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent, directory) 
	
os.rmdir(path)


directory = "Hello"
	
parent_dir = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent_dir, directory) 
os.rmdir(path)

directory = "Love"
	
parent_dir = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent_dir, directory) 
os.rmdir(path)


directory = "Main"
	
parent_dir = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent_dir, directory) 
os.rmdir(path)


directory = "My Crush"
	
parent_dir = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent_dir, directory)
os.rmdir(path)

directory = "Pictures"
	
parent_dir = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent_dir, directory) 
os.rmdir(path)

directory = "Prasad"
	
parent_dir = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent_dir, directory) 
os.rmdir(path)



directory = "Ramesh"
	
parent_dir = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent_dir, directory) 
os.rmdir(path)



directory = "Test"
	
parent_dir = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent_dir, directory) 
os.rmdir(path)



directory = "Last One"
	
parent_dir = "C:\\Users\\Ramesh Naidu\\Desktop\\Code World\\Python Tutorials"
	
path = os.path.join(parent_dir, directory) 
	
os.rmdir(path)

Here directory means Folders’ name that you are deleting with the help of this Script. So Change them as you want.

Note: Change parent_dir path to your own.

That’s it Now you can Delete Multiple Folders Just at One Click.

KSR

Hi there! I am the Founder of Cyber World Technologies. My skills include Android, Firebase, Python, PHP, and a lot more. If you have a project that you'd like me to work on, please let me know: contact@cyberworldtechnologies.co.in

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button