clean.py 409 B

12345678910111213
  1. import os
  2. # Define the root directory
  3. root_dir = "geoip/"
  4. # Loop through all subdirectories in the root directory
  5. for subdir in os.listdir(root_dir):
  6. subdir_path = os.path.join(root_dir, subdir)
  7. # Check if the subdirectory contains any txt files
  8. if not any(fname.endswith(".txt") for fname in os.listdir(subdir_path)):
  9. # If not, remove the subdirectory
  10. os.rmdir(subdir_path)