---
name: "filetypes"
section: "3tcl"
platform: "linux"
package: "tcllib"
version: "2.0+dfsg-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/filetypes"
---

# filetypes(3tcl)

Procedures implementing file-type recognition

```

```

## NAME

fileutil::magic::filetype - Procedures implementing file-type recognition

## SYNOPSIS

package require **Tcl 8.6 9**

package require **fileutil::magic::filetype ?2.0?**

**::fileutil::magic::filetype** *filename*

```

```

## DESCRIPTION

This package provides a command for the recognition of file types in pure Tcl.

The core part of the recognizer was generated from a "[magic(5)](/magic/5.md)" file containing the checks to perform to recognize files, and associated file-types.

*Beware!* This recognizer is large, about 752 Kilobyte of generated Tcl code.

- **::fileutil::magic::filetype** *filename*

  This command is similar to the command **fileutil::fileType**.

  Returns a list containing a list of descriptions, a list of mimetype components, and a list file extensions.  Returns an empty string if the file content is not recognized.

## REFERENCES

- \[1\]

  *File(1) sources* \[ftp://ftp.astron.com/pub/file/\] This site contains the current sources for the file command, including the magic definitions used by it. The latter were used by us to generate this recognizer.

## BUGS, IDEAS, FEEDBACK

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category *fileutil :: magic* of the *Tcllib Trackers* \[http://core.tcl.tk/tcllib/reportlist\]. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide *unified diffs*, i.e the output of **diff -u**.

Note further that *attachments* are strongly preferred over inlined patches. Attachments can be made by going to the **Edit** form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.

## SEE ALSO

[file(1)](/file/1.md), fileutil, [magic(5)](/magic/5.md)

## KEYWORDS

file recognition, file type, file utilities, type

## CATEGORY

Programming tools
