Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python remove directory not empty

import shutil

shutil.rmtree('/folder_name')
shutil.rmtree('/folder_name', ignore_errors=True)  # for read only files
Comment

empty directory if not empty python

'''
    Check if a Directory is empty : Method 1
'''    
if len(os.listdir('/home/varun/temp') ) == 0:
    print("Directory is empty")
else:    
    print("Directory is not empty")
Comment

PREVIOUS NEXT
Code Example
Python :: django queryset unique values 
Python :: reset index pandas 
Python :: python split string regular expression 
Python :: append attribute ofpython 
Python :: How do you print multiple things on one statement in Python? 
Python :: python count distinct letters 
Python :: python ls directory 
Python :: selenium scroll down python 
Python :: python clear screen windows and linux 
Python :: python move directory 
Python :: convert number to binary in python 
Python :: add rectangle matplotlib 
Python :: python print unicode character 
Python :: keep only duplicates pandas multiple columns 
Python :: count values in array python 
Python :: python slice an array 
Python :: get href scrapy xpath 
Python :: python prime check 
Python :: pandas group by count 
Python :: username nextcord interactions 
Python :: python get names of all classes 
Python :: discord.py cog 
Python :: python yaml load_all 
Python :: django dumpdata 
Python :: logging in with selenium 
Python :: python tempfile 
Python :: auto python to exe 
Python :: python replace first 
Python :: FileExistsError: [Errno 17] File exists: 
Python :: python cmath constants 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =