def empty_files(path, recursive=True):
    "Remove all files that are empty of any contents."
    for root, dirs, files in os.walk(path):
        if not recursive:
            del dirs[:]
        for name in files:
            filename = os.path.join(root, name)
            try:
                if not os.path.getsize(filename):
                    os.remove(filename)
            except OSError:
                pass
Remove all files that are empty of any contents.
recipes/Python/577635_Directory_Pruner_3/recipe-577635.py