Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a directory full of randomly named files of different types, all with no file extensions. Most are images, with some videos, and some plaintext. I've used one of the Windows versions of file to confirm the files can all be identified by their headers/metadata, but would like to automate the naming as there are roughly 2400 files.

I don't care so much about the filename as much as just having the appropriate extension for it's type. Is anyone aware of a program or script that can do this?

share|improve this question

3 Answers 3

up vote 1 down vote accepted

This seems to be similar to this question except that you require the files to be renamed in addition to simply identifying them. This can also be done with the same tool (TrID - File Identifier) that is mentioned in that question.

TrID is an utility designed to identify file types from their binary signatures. While there are similar utilities with hard coded logic, TrID has no fixed rules. Instead, it's extensible and can be trained to recognize new formats in a fast and automatic way. The definitions file (also downloadable from the same website) currently as 5000+ filetypes.

You can use command TrID on the command line with the -ae switch to instruct TrID to rename the files after identification. For example:

C:\TrID>trid c:\temp\* -ae


TrID/32 - File Identifier v2.20 - (C) 2003-15 By M.Pontello
Definitions found: 5702 Analyzing...

File: c:\temp\FILE0001.CHK 75.8% (.BAV) The Bat! Antivirus plugin (187530/5/21)

File: c:\temp\FILE0002.CHK 77.8% (.OGG) OGG Vorbis Audio (14014/3)

File: c:\temp\FILE0003.CHK 86.0% (.DOC) Microsoft Word document (49500/1/4)

File: c:\temp\FILE0004.CHK 42.6% (.EXE) UPX compressed Win32 Executable (30569/9/7)

4 file(s) renamed.

share|improve this answer
Just revisited this question and this answer is exactly what I was looking for when originally posted, thank you. – Infraded Jun 25 at 20:00

I've been told that this works. Though I've never been in a place to test.

If it seems to be a dud, has the linux file() command rewritten for use in a windows environment. then run a nice batch like this:

@echo off
dir /b "c:\(path to folder containing files)" >>files.txt
for /f %%i in (files.txt) do (
##use file /b and a set of conditionals with find to parse extensions  
based on header) del filelist.txt

Good Luck!

share|improve this answer

Under windows, there is filetype.exe and does exactly what you need. You can download it from here: It also contains a mini help.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.