1
0
Fork 0
python/filetypecheck.py

21 lines
612 B
Python

import os
directory_path = 'D:/root/videos'
def count_files_by_type(directory):
file_counts = {}
for root, dirs, files in os.walk(directory):
for file in files:
file_path = os.path.join(root, file)
file_extension = os.path.splitext(file_path)[1].lower()
if file_extension in file_counts:
file_counts[file_extension] += 1
else:
file_counts[file_extension] = 1
return file_counts
file_counts = count_files_by_type(directory_path)
for file_type, count in file_counts.items():
print(f"{file_type}: {count}")