else/Toolbox/allexecutables.py
2019-04-16 18:37:35 -07:00

15 lines
455 B
Python

import os
paths = os.getenv('PATH').split(';')
paths = [p for p in paths if os.path.exists(p)]
extensions = os.getenv('PATHEXT').split(';')
extensions = [e.lower() for e in extensions]
print('Extensions according to PATHEXT:', extensions)
for path in paths:
print(path)
files = os.listdir(path)
files = [f for f in files if any(f.lower().endswith(e) for e in extensions)]
files = [' ' + f for f in files]
print('\n'.join(files))