0

Checking Whether A Folder Is Empty Or Not.

How can i ckeck wether a folder is empty or not using python ? I'm creating a face recognition program in opencv and i need to check wether the folder where the testing image should be is empty ot not. Any help will be appreciated! Ty

Bohdan
  • 753
  • 1
  • 9
  • 18
  • 2
    Does this answer your question? [How to check if folder is empty with Python?](https://stackoverflow.com/questions/49284015/how-to-check-if-folder-is-empty-with-python) – rosa b. May 30 '22 at 20:43

1 Answers1

0

I'd do

if len(os.listdir(’path/to/your/folder’)) == 0:
    print("empty")
Axisnix
  • 2,822
  • 5
  • 19
  • 41
Elias
  • 9
  • 2