无法确定本地文件类型_如何从文件内容确定文件类型
無(wú)法確定本地文件類型
I. Introduction
一,引言
There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension. This reminded me of questions that come up here at EE along the lines of, "How can I tell the type of file from its contents?", as well as, "What kind of file has the XXX extension?" Writing an article to address this has been on my to-do list for a long time — the group discussion has inspired me to do it.
專家交流小組中正在進(jìn)行一個(gè)有趣的討論- 附件,不帶擴(kuò)展名 。 這讓我想起了EE中出現(xiàn)的問(wèn)題,例如“如何從文件內(nèi)容中區(qū)分文件類型?”以及“具有XXX擴(kuò)展名的文件類型”。 很久以來(lái),寫(xiě)一篇文章來(lái)解決這個(gè)問(wèn)題一直在我的工作清單上,小組討論啟發(fā)了我去做。
II. Determine the type of file from its XXX extension
二。 從文件的XXX擴(kuò)展名確定文件的類型
Here are five links that can help in determining what an XXX file is:
以下五個(gè)鏈接可幫助您確定XXX文件是什么:
http://extension.nirsoft.net/XXX
http://extension.nirsoft.net/XXX
https://www.file-extensions.org/XXX-file-extension
https://www.file-extensions.org/XXX-file-extension
http://www.fileinfo.com/extension/XXX
http://www.fileinfo.com/extension/XXX
http://filext.com/file-extension/XXX
http://filext.com/file-extension/XXX
http://www.solvusoft.com/en/file-extensions/file-extension-XXX
http://www.solvusoft.com/en/file-extensions/file-extension-XXX
Simply replace XXX with the file extension of interest. For example,
只需用感興趣的文件擴(kuò)展名替換XXX。 例如,
http://extension.nirsoft.net/TIFF
http://extension.nirsoft.net/TIFF
https://www.file-extensions.org/docx-file-extension
https://www.file-extensions.org/docx-file-extension
http://www.fileinfo.com/extension/AHK
http://www.fileinfo.com/extension/AHK
http://filext.com/file-extension/xhtml
http://filext.com/file-extension/xhtml
http://www.solvusoft.com/en/file-extensions/file-extension-opd
http://www.solvusoft.com/en/file-extensions/file-extension-opd
III. Determine the type of file from its contents
三, 根據(jù)文件內(nèi)容確定文件類型
Now to the trickier question! An excellent file identifier application called TrID analyzes the contents of a file in an attempt to figure out what type of file it is. It comes in both a command line interface (CLI) version (for Windows and Linux) and a Graphical User Interface (GUI) version (Windows only) called TrIDNet. The downloads are at the links in the preceding sentence.
現(xiàn)在到棘手的問(wèn)題! 一個(gè)名為TrID的出色文件標(biāo)識(shí)符應(yīng)用程序分析文件的內(nèi)容,以試圖弄清文件的類型。 它具有命令行界面(CLI)版本 (適用于Windows和Linux)和稱為TrIDNet的圖形用戶界面(GUI)版本 (僅適用于Windows)。 下載位于前一句中的鏈接。
Both the CLI and GUI versions require a database/library of file definitions. This is a key feature of TrID and TrIDNet — the always increasing list of files that it recognizes. As of this article's submission date, the database contains 6,019 definitions (dated 13-August-2015). Note that there are separate downloads for the CLI definitions and the GUI definitions.
CLI和GUI版本都需要文件定義的數(shù)據(jù)庫(kù)/庫(kù)。 這是TrID和TrIDNet的主要功能-TrID和TrIDNet可以識(shí)別的文件列表總是在增加。 截至本文提交之日,該數(shù)據(jù)庫(kù)包含6,019個(gè)定義 (日期為2015年8月13日)。 請(qǐng)注意, CLI定義和GUI定義有單獨(dú)的下載。
IV. More about TrID — the CLI version
IV。 有關(guān)TrID的更多信息-CLI版本
After downloading the CLI version and its definitions, simply unpack the ZIP file with the program (trid.exe) and copy the definitions file (triddefs.trd) into the same folder as the program file. As mentioned above, using a database of definitions for file types is a really nice feature of TrID. Since file types are frequently added, the program author makes the definitions database available as a separate download, so you may go back to the website occasionally to get the latest definitions file.
下載CLI版本及其定義后,只需使用程序( trid.exe )解壓縮ZIP文件,然后將定義文件( triddefs.trd )復(fù)制到與程序文件相同的文件夾中。 如上所述,使用文件類型定義數(shù)據(jù)庫(kù)是TrID的一個(gè)非常不錯(cuò)的功能。 由于經(jīng)常添加文件類型,因此程序作者可以單獨(dú)下載定義數(shù)據(jù)庫(kù),因此您有時(shí)可能會(huì)返回網(wǎng)站以獲取最新的定義文件。
Here's the syntax of the CLI version (v2.20):
這是CLI版本(v2.20)的語(yǔ)法:
Usage: TrID <[path]filespec(s)...> [-ae|-ce] [-d:file] [-ns] [-n:nn][-@] [-v] [-w] [-?]Where: <filespec> Files to identify/analyze-ae Add guessed extension to filename-ce Change filename extension-d:file Use the specified defs package-ns Disable unique strings check-n:nn Number of matches to show (default: 5)-@ Read file list from stdin-v Verbose mode - display def name, author, etc.-w Wait for a key before exiting-? This help!The program is free for personal use. Here's exactly what the license says (I took the liberty of correcting typos in it):
該程序免費(fèi)供個(gè)人使用。 這正是許可證所說(shuō)的內(nèi)容(我可以糾正其中的錯(cuò)別字):
The program can be freely distributed and is freeware for non-commercial, personal, research and educational use. Contact the author for commercial use or commercialization of TrID or TrID's definitions and contained information.
該程序可以免費(fèi)分發(fā),并且是非商業(yè),個(gè)人,研究和教育用途的免費(fèi)軟件。 聯(lián)系作者以用于TrID或TrID的定義和所含信息的商業(yè)用途或商業(yè)化。
I don't want to put the author's email address in this article, but you may find it in the Readme file that is part of the download.
我不想在本文中放入作者的電子郵件地址,但是您可以在下載的自述文件中找到它。
V. More about TrIDNet — the GUI version
V.有關(guān)TrIDNet的更多信息-GUI版本
As stated earlier, the definitions for the GUI version are in a different format from the definitions for the command line version. The GUI definitions are in a large number of XML files, one for each file type — currently, 6,019 of them!
如前所述,GUI版本的定義與命令行版本的定義格式不同。 GUI定義包含在大量XML文件中,每種文件類型對(duì)應(yīng)一個(gè)XML文件-當(dāng)前共有6,019個(gè)!
As with the CLI version, there's no installation needed — just unpack the ZIP file with the program (TrIDNet.exe) and copy the definitions (all of the XML files) into the same folder as the program file.
與CLI版本一樣,不需要安裝-只需使用程序( TrIDNet.exe )解壓縮ZIP文件,然后將定義( 所有 XML文件)復(fù)制到程序文件所在的文件夾中即可。
When running TrIDNet, here's the opening screen:
運(yùn)行TrIDNet時(shí),這是打開(kāi)屏幕:
V. Conclusion
五,結(jié)論
To come full circle to the group discussion that prompted this article, I fed to both TrID and TrIDNet a file that has 40 characters in the file name but no file extension. Here's the TrID command line with its result (via copy/paste from the command prompt window):
為了使引起本文討論的小組討論全面進(jìn)行,我向TrID和TrIDNet提供了一個(gè)文件名,該文件名包含40個(gè)字符,但沒(méi)有文件擴(kuò)展名。 這是TrID命令行及其結(jié)果(通過(guò)從命令提示符窗口復(fù)制/粘貼):
trid "d:\0tempd\40 character file name without extension"
trid“ d:\ 0tempd \ 40個(gè)字符文件名,不帶擴(kuò)展名”
TrID/32 - File Identifier v2.20 - (C) 2003-15 By M.Pontello
TrID / 32-文件標(biāo)識(shí)符v2.20-(C)2003-15通過(guò)M.Pontello
Definitions found: ?6019
找到的定義:6019
Analyzing...
分析...
Collecting data from file: d:\0tempd\40 character file name without extension
從文件收集數(shù)據(jù):d:\ 0tempd \ 40個(gè)字符文件名,不帶擴(kuò)展名
100.0% (.PDF) Adobe Portable Document Format (5000/1)
100.0%(.PDF)Adobe可移植文檔格式(5000/1)
Here's the TrID GUI result:
這是TrID GUI結(jié)果:
Both TrID and TrIDNet easily determined that it is a PDF file — and with 100% certainty. Of course, 100% certainty is not always the case, as shown in this real-life example of a file uploaded in a recent EE question. The file bumped into the 40-character file name limit and wound up with a .x file extension. Here are the TrID results on it:
TrID和TrIDNet都可以輕松確定它是PDF文件,并且具有100%的確定性。 當(dāng)然,并非總是100%的確定性,如在最近的EE問(wèn)題中上傳的文件的真實(shí)示例所示。 該文件達(dá)到40個(gè)字符的文件名限制,并以.x文件擴(kuò)展名結(jié)尾 。 這是TrID的結(jié)果:
TrID/32 - File Identifier v2.20 - (C) 2003-15 By M.Pontello
TrID / 32-文件標(biāo)識(shí)符v2.20-(C)2003-15通過(guò)M.Pontello
Definitions found: ?6019
找到的定義:6019
Analyzing...
分析...
Collecting data from file: d:\0tempD\Time-Interval-Frequency-calculationv51.x
從文件收集數(shù)據(jù):d:\ 0tempD \ Time-Interval-Frequency-calculationv51.x
?51.3% (.XLSM) Excel Microsoft Office Open XML Format document (with Macro) (57500/1/12)
51.3%(.XLSM)Excel Microsoft Office Open XML格式文檔(帶有宏)(57500/1/12)
?45.0% (.XLSX) Excel Microsoft Office Open XML Format document (50500/1/11)
45.0%(.XLSX)Excel Microsoft Office Open XML格式文檔(50500/1/11)
? 3.5% (.ZIP) ZIP compressed archive (4000/1)
3.5%(.ZIP)ZIP壓縮存檔(4000/1)
It is, in fact, a .XLSM file, as predicted by TrID, although with only 51.3% certainty. After changing the file type from .x to .xlsm, it loaded perfectly into Excel.
實(shí)際上, 正如TrID預(yù)測(cè)的那樣,它是.XLSM文件,盡管只有51.3%的確定性。 將文件類型從.x更改為.xlsm之后 ,它完美地加載到Excel中。
If you find this article to be helpful, please click the thumbs-up icon below. This lets me know what is valuable for EE members and provides direction for future articles. Thanks very much! Regards, Joe
如果您發(fā)現(xiàn)本文有幫助,請(qǐng)單擊下面的大拇指圖標(biāo)。 這使我知道什么對(duì)EE成員有價(jià)值,并為以后的文章提供了指導(dǎo)。 非常感謝! 問(wèn)候喬
翻譯自: https://www.experts-exchange.com/articles/19759/How-to-determine-the-type-of-file-from-its-contents.html
無(wú)法確定本地文件類型
總結(jié)
以上是生活随笔為你收集整理的无法确定本地文件类型_如何从文件内容确定文件类型的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: SURF网格化特征点提取算法流程(一)
- 下一篇: IDRLP: Image Dehazin