Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from os import sep
- from os.path import join, split
- from subprocess import check_output
- def run_script(file_path):
- try:
- result = str(check_output(['file', file_path]))
- except Exception as e:
- result = str(e)
- return result
- def check_dicoms(path):
- itemlist = []
- tabs = ["\t"]
- with open('log.txt', 'w') as h:
- h.write("\n")
- for root, dirs, files in os.walk(path):
- print(root)
- rspit = split(root)
- ntabs = rspit[0].count(sep)
- croot = rspit[1]
- itemlist.append(''.join(tabs * ntabs + [croot]))
- ntabs += 1
- for filename in files:
- if filename == 'v_headers' or filename == 'v_headers.index':
- continue
- row = [filename, ' - ', run_script(os.path.join(root, filename))]
- itemlist.append(''.join(tabs * ntabs + row))
- with open('log.txt', 'a') as h:
- h.write("\n".join(itemlist))
- check_dicoms('asd')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement