Jul-20-2021, 01:50 AM
Greetings!
I have directories with an empty file or two, I want to identify and delete them.
I thought I could use Path().stat().st_size but the code fails to identify those derectories.
I have directories with an empty file or two, I want to identify and delete them.
I thought I could use Path().stat().st_size but the code fails to identify those derectories.
import pathlib for ef in pathlib.Path('C:\\02').iterdir() : if ef.is_dir() : print(f" Directory -> {ef}") tt = pathlib.Path(ef).stat().st_size print(f" Size -> {tt}") if tt==0 : print(f" Empty Dir -> {tt}") else : print(f"Not Empty Dir ->{tt}")Thank you.