how to check if the directory is empty in python code example
Example 1: python check if folder is empty
if not os.listdir('/home/varun/temp') :
print("Directory /home/varun/temp is empty")
Example 2: 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")