[Cialug] List file types in a directory
kristau
kristau at gmail.com
Thu Mar 8 22:04:55 CST 2007
On 3/8/07, Daniel Juliano <dan at danandlaurajuliano.com> wrote:
> So, how would I get a list of file types for all files in a directory?
> Let's say I've got the following:
> test1.txt
> test2.txt
> test3.jpg
>
> I'd like something similar to:
> .txt
> .jpg
>
> Any ideas?
If you can trust that the file extensions correlate reliably to the
actual file types, then most of the methods listed here will work OK.
However, if you cannot make this assumption, 'file' will inspect each
file and give you a good guess at its format.
'file' can make mistakes, though. I ran it against a folder with
Quicken .QIF files in it and they were identified as "Assembler
source". I don't think I'm going to try running those through nasm,
though.
;)
--
Tired programmer
Coding late into the night
The core dump follows
My GNUPG public key is available at http://www.kristau.net/public_key.asc
More information about the Cialug
mailing list