MIMETYPE(1p) | User Contributed Perl Documentation | MIMETYPE(1p) |
mimetype - Determine file type
mimetype [options] [-] files
This script tries to determine the mime type of a file using the Shared MIME-info database. It is intended as a kind of file(1) work-alike, but uses mimetypes instead of descriptions.
If one symlinks the file command to mimetype it will behave a little more compatible, see "--file-compat". Commandline options to specify alternative magic files are not implemented the same because of the conflicting data formats. Also the wording of the descriptions will differ.
For naming switches I followed the manpage of file(1) version 4.02 when possible. They seem to differ completely from the spec in the 'utilities' chapter of IEEE Std 1003.1-2001 (POSIX).
TODO: this method now just returns one match for each method (globs, magic, etc.).
A single '-' won't be considered a separator between options and filenames anymore, but becomes identical to "--stdin". ( You can still use '--' as separator, but that is not backward compatible with the original file command. ) Also the default becomes to print descriptions instead of mimetypes.
%f for the filename %d description %m mime type
Alignment is not available when using this, you need to post-process the output to do that.
To use this option IO::Scalar needs to be installed.
$HOME/.local/share/mime /usr/local/share/mime /usr/share/mime
See also the "XDG Base Directory Specification" <http://freedesktop.org/Standards/basedir-spec>
The base dir for all data files is determined by two environment variables, see "ENVIRONMENT".
If a file has an empty mimetype or an empty description, most probably the file doesn't exist and the given name doesn't match any globs. An empty description can also mean that there is no description available in the language you specified.
The program exits with a non-zero exit value if either the commandline arguments failed, a module it depends on wasn't found or the shared mime-info database wasn't accessible. See File::MimeInfo for more details.
The '--all' switch doesn't really show all matches, but only one per mime-typing method. This needs to be implemented in the modules first.
If you find bugs, please file them in our Github issue tracker at <https://github.com/mbeijen/File-MimeInfo/issues>.
mimetype doesn't provide a switch for looking inside compressed files because it seems to me that this can only be done by un-compressing the file, something that defeats the purpose. On the other hand the option should exist for strict compatibility with file(1). Possibly a subclass should be made for this one day.
Jaap Karssenberg <pardus@cpan.org> Maintained by Michiel Beijen <mb@x14.nl>
Copyright (c) 2003, 2012 Jaap G Karssenberg. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
file(1), update-mime-database(1), File::MimeInfo(3), <http://freedesktop.org/Software/shared-mime-info>
2022-07-15 | perl v5.34.0 |