How to get a Summary of Every File Type in a Folder at the Command Line

This command will work on Linux and MacOS. Here we’re running it on our downloads folder to get a summary of every type of file in the folder.

Run a the command line

for file in ~/Downloads/*; do file "$file" | cut -d: -f 2; done | sort -u

Output:

 ASCII text
 ASCII text, with CRLF line terminators
 ASCII text, with very long lines
 HTML document text, ASCII text
 HTML document text, ASCII text, with very long lines
 HTML document text, UTF-8 Unicode text, with very long lines
 Microsoft Excel 2007+
 Microsoft PowerPoint 2007+
 Microsoft Word 2007+
 PDF document, version 1.3
 PDF document, version 1.5
 PDF document, version 1.7
 PHP script text, ASCII text, with very long lines
 PNG image data, 200 x 62, 8-bit/color RGBA, non-interlaced
 RFC 822 mail text, ASCII text, with very long lines
 SMTP mail text, ASCII text, with CRLF line terminators
 SMTP mail text, UTF-8 Unicode text, with very long lines, with CRLF line terminators
 UTF-8 Unicode (with BOM) text, with CRLF line terminators
 UTF-8 Unicode text
 Zip archive data, at least v1.0 to extract
 Zip archive data, at least v2.0 to extract
 data
 directory

Leave a Reply

Your email address will not be published. Required fields are marked *