I want to search my computer drives D to Z for all vhdx files, and calculate the total amount of them. But I want to exclude directories. How to change my code?
extf = ['$RECYCLE.BIN','System Volume Information']
import os
i = 0
az = lambda: (chr(i)+":\\" for i in range(ord("D"), ord("Z") + 1))
for drv in az():
for root, dirs, files in os.walk(drv):
for filename in files:
splitname = filename.split('.')
if splitname[-1] !="vhdx":
continue
file_path = (os.path.join(root, filename))
print file_path
i += 1
if i != 0:
print ("total vhdx files:",i)