Show detailed metadata for any file -- images, audio, video, archives, PDFs, and more.
pip install whatfileNo heavy dependencies required. Optional backends (Pillow, tinytag, pypdf) add more detail automatically when installed.
whatfile photo.jpg song.mp3 video.mp4 archive.zip document.pdf script.py| Format | Info shown | Optional dep |
|---|---|---|
| JPEG, PNG, GIF, WebP, BMP, TIFF, AVIF | dimensions, color mode, format | pip install Pillow |
| MP3, FLAC, OGG, WAV, M4A, OPUS | duration, bitrate, samplerate, tags | pip install tinytag (or ffprobe) |
| MP4, MKV, AVI, MOV, WebM | codec, resolution, fps, duration, bitrate | ffprobe (from ffmpeg) |
| ZIP, TAR, GZ, BZ2, XZ, 7z, RAR | file count, compressed/uncompressed size | stdlib (7z/unrar for extra) |
| pages, version, title, author | pip install pypdf (or pdfinfo) |
|
| Any file | size, permissions, MIME type | none |
Everything works out of the box. Optional backends enrich the output -- no errors if missing.
# Multiple files at once
whatfile report.pdf screenshot.png backup.tar.gz
# Wildcard (shell expansion)
whatfile ~/Music/*.flac
# All files in directory
whatfile ~/Downloads/*whatfile classifies files by extension, then dispatches to the appropriate backend. Each backend inspects the file and returns structured metadata. A pretty box-drawing display renders the result.
Detection order per format:
- Image -- Pillow (if installed) extracts dimensions, mode, format
- Audio -- tinytag (if installed) for tags + codec info; falls back to ffprobe
- Video -- ffprobe for codecs, resolution, duration
- Archive -- stdlib zipfile/tarfile for entries + compression ratio; 7z/unrar subprocess for extra formats
- PDF -- pypdf (if installed) for pages, version, metadata; falls back to pdfinfo
- Generic -- os.stat for size/permissions; python-magic or
filecommand for MIME type
MIT