1MIMETYPE(1)           User Contributed Perl Documentation          MIMETYPE(1)
2
3
4

NAME

6       mimetype - Determine file type
7

SYNOPSIS

9       mimetype [options] [-] files
10

DESCRIPTION

12       This script tries to determine the mime type of a file using the Shared
13       MIME-info database. It is intended as a kind of file(1) work-alike, but
14       uses mimetypes instead of descriptions.
15
16       If one symlinks the file command to mimetype it will behave a little
17       more compatible, see "--file-compat".  Commandline options to specify
18       alternative magic files are not implemented the same because of the
19       conflicting data formats.  Also the wording of the descriptions will
20       differ.
21
22       For naming switches I followed the manpage of file(1) version 4.02 when
23       possible. They seem to differ completely from the spec in the
24       'utilities' chapter of IEEE Std 1003.1-2001 (POSIX).
25

OPTIONS

27       -a, --all
28           Show output of all rules that match the file.
29
30           TODO: this method now just returns one match for each method
31           (globs, magic, etc.).
32
33       -b, --brief
34           Do not prepend filenames to output lines (brief mode).
35
36       --database=mimedir:mimedir:...
37           Force the program to look in these directories for the shared mime-
38           info database. The directories specified by the basedir
39           specification are ignored.
40
41       -d, --describe
42           Print file descriptions instead of mime types, this is the default
43           when using "--file-compat".
44
45       -D, --debug
46           Print debug information about how the mimetype was determined.
47
48       -f namefile, --namefile=namefile
49           Read the names of the files to be examined from the file 'namefile'
50           (one per line) before the argument list.
51
52       --file-compat
53           Make mimetype behave a little more file(1) compatible. This is
54           turned on automatically when you call mimetype by a link called
55           'file'.
56
57           A single '-' won't be considered a separator between options and
58           filenames anymore, but becomes identical to "--stdin".  ( You can
59           still use '--' as separator, but that is not backward compatible
60           with the original file command. ) Also the default becomes to print
61           descriptions instead of mimetypes.
62
63       -F string, --separator=string
64           Use string as custom separator between the file name and its
65           mimetype or description, defaults to ':' .
66
67       -h, --help
68       -u, --usage
69           Print a help message and exits.
70
71       -i, --mimetype
72           Use mime types, opposite to "--describe", this is the default when
73           _not_ using "--file-compat".
74
75       -L, --dereference
76           Follow symbolic links.
77
78       -l code, --language=code
79           The language attribute specifies a two letter language code, this
80           makes descriptions being outputted in the specified language.
81
82       -M, --magic-only
83           Do not check for extensions, globs or inode type, only look at the
84           content of the file. This is particularly useful if for some reason
85           you don't trust the name or the extension a file has.
86
87       -N, --noalign
88           Do not align output fields.
89
90       --output-format
91           If you want an alternative output format, you can specify a format
92           string containing the following escapes:
93
94               %f for the filename
95               %d description
96               %m mime type
97
98           Alignment is not available when using this, you need to post-
99           process the output to do that.
100
101       --stdin
102           Determine type of content from STDIN, less powerful then normal
103           file checking because it only uses magic typing. This will happen
104           also if the STDIN filehandle is a pipe.
105
106           To use this option IO::Scalar needs to be installed.
107
108       -v, --version
109           Print the version of the program and exit.
110

ENVIRONMENT

112       XDG_DATA_HOME
113       XDG_DATA_DIRS
114           These variables can list base directories to search for data files.
115           The shared mime-info will be expected in the "mime" sub directory
116           of one of these directories. If these are not set, there will be
117           searched for the following directories:
118
119               $HOME/.local/share/mime
120               /usr/local/share/mime
121               /usr/share/mime
122
123           See also the "XDG Base Directory Specification"
124           <http://freedesktop.org/Standards/basedir-spec>
125

FILES

127       The base dir for all data files is determined by two environment
128       variables, see "ENVIRONMENT".
129
130       BASE/mime/packages/SOURCE.xml
131           All other files are compiled from these source files. To re-compile
132           them use update-mime-database(1).
133
134       BASE/mime/globs
135           Compiled information about globs.
136
137       BASE/mime/magic
138           Compiled information about magic numbers.
139
140       BASE/mime/MEDIA/SUBTYPE.xml
141           Descriptions of a mimetype in multiple languages, used for the
142           "--describe" switch.
143

DIAGNOSTICS

145       If a file has an empty mimetype or an empty description, most probably
146       the file doesn't exist and the given name doesn't match any globs. An
147       empty description can also mean that there is no description available
148       in the language you specified.
149
150       The program exits with a non-zero exit value if either the commandline
151       arguments failed, a module it depends on wasn't found or the shared
152       mime-info database wasn't accessible. See File::MimeInfo for more
153       details.
154

TODO

156       The '--all' switch doesn't really show all matches, but only one per
157       mime-typing method. This needs to be implemented in the modules first.
158

BUGS

160       If you find bugs, please file them in our Github issue tracker at
161       <https://github.com/mbeijen/File-MimeInfo/issues>.
162
163       mimetype doesn't provide a switch for looking inside compressed files
164       because it seems to me that this can only be done by un-compressing the
165       file, something that defeats the purpose. On the other hand the option
166       should exist for strict compatibility with file(1). Possibly a subclass
167       should be made for this one day.
168

AUTHOR

170       Jaap Karssenberg <pardus@cpan.org> Maintained by Michiel Beijen
171       <mb@x14.nl>
172
174       Copyright (c) 2003, 2012 Jaap G Karssenberg. All rights reserved.  This
175       program is free software; you can redistribute it and/or modify it
176       under the same terms as Perl.
177
178       This program is distributed in the hope that it will be useful, but
179       WITHOUT ANY WARRANTY; without even the implied warranty of
180       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
181

SEE ALSO

183       file(1), update-mime-database(1), File::MimeInfo(3),
184       <http://freedesktop.org/Software/shared-mime-info>
185
186
187
188perl v5.34.0                      2022-03-07                       MIMETYPE(1)
Impressum