Skip to content

Instantly share code, notes, and snippets.

@glens
Created May 31, 2022 07:48
Show Gist options
  • Save glens/6a65f6d92ab863cd2393d08660ae362c to your computer and use it in GitHub Desktop.
Save glens/6a65f6d92ab863cd2393d08660ae362c to your computer and use it in GitHub Desktop.
list folder contents and guess file mimetype
#!/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