#====
#This script will check how many files in sub-folders.
#Will delete the sub-folders if the files are not enough.
#====

import os
import shutil
from os import walk
import os.path

#mypath='./'
mypath='/home/xxx/awk/'

num = 6
count_at_least = 0

for (dirpath, dirnames, filenames) in walk(mypath):

   for dir in dirnames:

       for (dirpath1, dirnames1, filenames1) in walk(mypath+dir):
          if len(filenames1) < num:
              count_at_least = count_at_least + 1
              print(dirpath1)
            # shutil.rmtree(dirpath1)

print('Less than {} images per class is {}. Will delete.'.format(num,count_at_least) )


#http://blog.csdn.net/duhai/article/details/22404627
#http://www.jb51.net/article/57293.htm
#https://www.cnblogs.com/dwtt/p/7772639.html

 

相关文章:

  • 2021-10-19
  • 2021-11-17
  • 2021-12-27
  • 2021-08-15
  • 2021-10-29
  • 2022-12-23
  • 2021-09-23
  • 2021-10-07
猜你喜欢
  • 2021-10-18
  • 2022-12-23
  • 2021-07-01
  • 2022-12-23
  • 2021-05-15
  • 2021-07-16
  • 2022-12-23
相关资源
相似解决方案