Command-Line
如何在命令行的幫助下列印文件的元數據?
我正在使用安裝了 Nautilus 3.10.1 的Trisquel 7.0。
每當我顯示文件的屬性時,我都會有一個特定於文件的選項卡,例如:圖像、音頻/影片、文件等,它顯示有關它的特殊資訊。
圖像範例:
PDF 文件的範例:
Nautilus 如何獲取此類特定於文件的資訊?
以及如何使用命令行列印此資訊(元數據)?
對於命令行中的第一級資訊,您可以使用
file
.$ file gtu.pdf gtu.pdf: PDF document, version 1.4
對於大多數格式和更詳細的資訊,您還可以使用 Exiftool:
NAME exiftool - Read and write meta information in files SYNOPSIS exiftool [OPTIONS] [-TAG...] [--TAG...] FILE... exiftool [OPTIONS] -TAG[+-<]=[VALUE]... FILE... exiftool [OPTIONS] -tagsFromFile SRCFILE [-SRCTAG[>DSTTAG]...] FILE... exiftool [ -ver | -list[w|f|r|wf|g[NUM]|d|x] ] For specific examples, see the EXAMPLES sections below. This documentation is displayed if exiftool is run without an input FILE when one is expected. DESCRIPTION A command-line interface to Image::ExifTool, used for reading and writing meta information in a variety of file types. FILE is one or more source file names, directory names, or "-" for the standard input. Information is read from source files and printed in readable form to the console (or written to output text files with -w).
例子:
$ exiftool IMG_20151104_102543.jpg ExifTool Version Number : 9.46 File Name : IMG_20151104_102543.jpg Directory : . File Size : 2.8 MB File Modification Date/Time : 2015:11:04 10:25:44+05:30 File Access Date/Time : 2015:11:17 18:56:49+05:30 File Inode Change Date/Time : 2015:11:11 14:55:43+05:30 File Permissions : rwxrwxrwx File Type : JPEG MIME Type : image/jpeg Exif Byte Order : Big-endian (Motorola, MM) GPS Img Direction : 0 GPS Date Stamp : 2015:11:04 GPS Img Direction Ref : Magnetic North GPS Time Stamp : 04:55:43 Camera Model Name : Micromax A121 Aperture Value : 2.1 Interoperability Index : R98 - DCF basic file (sRGB) Interoperability Version : 0100 Create Date : 2002:12:08 12:00:00 Shutter Speed Value : 1/808 Color Space : sRGB Date/Time Original : 2015:11:04 10:25:44 Flashpix Version : 0100 Exif Image Height : 2400 Exif Version : 0220 Exif Image Width : 3200 Focal Length : 3.5 mm Flash : Auto, Did not fire Exposure Time : 1/809 ISO : 100 Components Configuration : Y, Cb, Cr, - Y Cb Cr Positioning : Centered Y Resolution : 72 Resolution Unit : inches X Resolution : 72 Make : Micromax Compression : JPEG (old-style) Thumbnail Offset : 640 Thumbnail Length : 12029 Image Width : 3200 Image Height : 2400 Encoding Process : Baseline DCT, Huffman coding Bits Per Sample : 8 Color Components : 3 Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2) Aperture : 2.1 GPS Date/Time : 2015:11:04 04:55:43Z Image Size : 3200x2400 Shutter Speed : 1/809 Thumbnail Image : (Binary data 12029 bytes, use -b option to extract) Focal Length : 3.5 mm Light Value : 11.9
某些類型的文件也有特定的命令,例如pdf:
$ pdfinfo gtu.pdf Title: Microsoft Word - Thermax Ltd Author: User Creator: PScript5.dll Version 5.2.2 Producer: GPL Ghostscript 8.15 CreationDate: Tue Jan 27 11:51:38 2015 ModDate: Tue Jan 27 12:30:40 2015 Tagged: no Form: none Pages: 1 Encrypted: no Page size: 612 x 792 pts (letter) Page rot: 0 File size: 64209 bytes Optimized: yes PDF version: 1.4