1MIMETYPE(1) User Contributed Perl Documentation MIMETYPE(1)
2
3
4
6 mimetype - Determine file type
7
9 mimetype [options] [-] files
10
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
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 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
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 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
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 <http://freedesktop.org/Standards/basedir-spec>
126
128 The base dir for all data files is determined by two environment
129 variables, see "ENVIRONMENT".
130
131 BASE/mime/packages/SOURCE.xml
132 All other files are compiled from these source files. To re-compile
133 them use update-mime-database(1).
134
135 BASE/mime/globs
136 Compiled information about globs.
137
138 BASE/mime/magic
139 Compiled information about magic numbers.
140
141 BASE/mime/MEDIA/SUBTYPE.xml
142 Descriptions of a mimetype in multiple languages, used for the
143 "--describe" switch.
144
146 If a file has an empty mimetype or an empty description, most probably
147 the file doesn't exist and the given name doesn't match any globs. An
148 empty description can also mean that there is no description available
149 in the language you specified.
150
151 The program exits with a non-zero exit value if either the commandline
152 arguments failed, a module it depends on wasn't found or the shared
153 mime-info database wasn't accesable. See File::MimeInfo for more
154 details.
155
157 The '--all' switch doesn't really show all matches, but only one per
158 mime-typing method. This needs to be implemnted in the modules first.
159
161 No known bugs, please mail the author if you find one.
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
170 Jaap Karrssenberg <pardus@cpan.org>
171
173 Copyright (c) 2003,2008 Jaap G Karssenberg. All rights reserved. This
174 program is free software; you can redistribute it and/or modify it
175 under the same terms as Perl.
176
177 This program is distributed in the hope that it will be useful, but
178 WITHOUT ANY WARRANTY; without even the implied warranty of
179 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
180
182 file(1), update-mime-database(1), File::MimeInfo(3),
183 http://freedesktop.org/Software/shared-mime-info
184 <http://freedesktop.org/Software/shared-mime-info>
185
186
187
188perl v5.12.0 2010-05-01 MIMETYPE(1)