Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python remove empty folders

import os
def drop_empty_folders(directory):
    """Verify that every empty folder removed in local storage."""

    for dirpath, dirnames, filenames in os.walk(directory, topdown=False):
        if not dirnames and not filenames:
            os.rmdir(dirpath)
Comment

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 :: save plot as image python matplotlib 
Python :: filter rows pandas 
Python :: how to create a custom callback function in keras while training the model 
Python :: update python in cmd 
Python :: take off character in python string 
Python :: is alphabet python 
Python :: django form datepicker 
Python :: numpy stdev 
Python :: previous value list loop python 
Python :: fake migration 
Python :: python how to return max num index 
Python :: pandas drop columns by index 
Python :: python tkinter delete label 
Python :: python select random subset from numpy array 
Python :: crop image python 
Python :: python how to get every name in folder 
Python :: python in line conditional statement 
Python :: matplotlib set number of decimal places 
Python :: pandas read csv as strings 
Python :: split multiple times 
Python :: how to convert string to function name in python 
Python :: pd max rows set option 
Python :: np replace nan 
Python :: python opencv open camera 
Python :: download files requests python 
Python :: array search with regex python 
Python :: Make A Snake Game Using Python and Pygame 
Python :: pandas read csv unnamed 0 
Python :: how to insert a variable into a string without breaking up the string in python 
Python :: python read music stream 
ADD CONTENT
Topic
Content
Source link
Name
4+7 =