Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sys
- if len(sys.argv) == 1:
- exit()
- path = sys.argv[-1]
- if len(sys.argv) > 1 :
- commandArgs = sys.argv[1:-1]
- items = []
- # for item in os.listdir(path):
- for (dirpath, folders, files) in os.walk(path):
- if dirpath == path or '-R' in commandArgs:
- for item in (files + folders):
- if item[0] != '.' or ("-a" in commandArgs and item[0] == '.'):
- if "-d" in commandArgs:
- if not os.path.isfile(dirpath + '/' + item):
- a = len([i for i in os.listdir(dirpath + '/' + item) if os.path.isfile(dirpath + '/' + item + '/' + i)])
- items.append(item + ' ' + str(a) + ' (Files)')
- else:
- items.append(item)
- if "-r" in commandArgs:
- items = list(reversed(items))
- for i in items:
- print(i)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement