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 'utili‐
24       ties' 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 specifica‐
39           tion 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 automaticly when you call mimetype by a link called
55           'file'.
56
57           A single '-' won't be considered a seperator between options and
58           filenames anymore, but becomes identical to "--stdin".  ( You can
59           still use '--' as seperator, 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 mime‐
65           type 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 powerfull 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" <http://freedesk
124           top.org/Standards/basedir-spec>
125

FILES

127       The base dir for all data files is determined by two environment vari‐
128       ables, 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 accesable. 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 implemnted in the modules first.
158

BUGS

160       No known bugs, please mail the author if you find one.
161
162       mimetype doesn't provide a switch for looking inside compressed files
163       because it seems to me that this can only be done by un-compressing the
164       file, something that defeats the purpose. On the other hand the option
165       should exist for strict compatibility with file(1). Possibly a subclass
166       should be made for this one day.
167

AUTHOR

169       Jaap Karrssenberg <pardus@cpan.org>
170
172       Copyright (c) 2003 Jaap G Karssenberg. All rights reserved.  This pro‐
173       gram is free software; you can redistribute it and/or modify it under
174       the same terms as Perl.
175
176       This program is distributed in the hope that it will be useful, but
177       WITHOUT ANY WARRANTY; without even the implied warranty of MER‐
178       CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
179

SEE ALSO

181       file(1), update-mime-database(1), File::MimeInfo(3), <http://freedesk
182       top.org/Software/shared-mime-info>
183
184
185
186perl v5.8.8                       2006-11-16                       MIMETYPE(1)
Impressum