Skip to content

Instantly share code, notes, and snippets.

@dukn
Created July 27, 2018 10:34
Show Gist options
  • Save dukn/fe0523f8be7bce26faeeaf6d2c3bbce5 to your computer and use it in GitHub Desktop.
Save dukn/fe0523f8be7bce26faeeaf6d2c3bbce5 to your computer and use it in GitHub Desktop.
import os
def count(path):
ld = os.listdir(path)
#print (ld)
result = 0
for name in ld:
if os.path.isdir(path+'/'+name):
#print (name)
ld2 = os.listdir("{}/{}/".format(path,name))
result += len(ld2)
else:
result += 1
return result
def check():
ld = os.listdir()
if __name__ == '__main__':
ar = []
for dr in os.listdir("./"):
if os.path.isdir(dr):
ar.append([count(path=dr),dr])
ar = sorted(ar ,key=lambda x:x[0])
for b,a in ar:
print (a,':',b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment