Created
May 31, 2022 07:48
-
-
Save glens/6a65f6d92ab863cd2393d08660ae362c to your computer and use it in GitHub Desktop.
list folder contents and guess file mimetype
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import mimetypes | |
import os | |
import sys | |
path = sys.argv[1] | |
for file in os.listdir(path): | |
file_mimetype = str(mimetypes.guess_type(file)[0]) | |
print('{} {}'.format(file_mimetype, file)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment