Use built-in unix command `stat` instead of `exiftool`
The part you want to Enhancement
We can get file attributes without additional programs, but use the built-in stat utility.
Why it is necessary to enhancement
We won't need to install a third party program.
Additional context
Windows also has an alternative command: Windows equivalent to the unix "stat" command?. You may also find this useful: stat(1) — Linux manual page.
Here's what it looks like on macOS and ubuntu. You can also specify the output format you want via the --format argument.
Looks great. It will be better if we don't need to install another tool.
@yorukot @MrPandir stat is unable to figure out if a file is binary file or not .
stat doesn't seem to be able to provide enough info about the file to replace exiftool
➜ ~/temp/testf/tough [2:35:06] stat -x ./binary/go
File: "./binary/go"
Size: 16062450 FileType: Regular File
Mode: (0755/-rwxr-xr-x) Uid: ( 501/kuknitin) Gid: ( 20/ staff)
Device: 1,14 Inode: 85816045 Links: 1
Access: Fri Jan 24 02:33:47 2025
Modify: Fri Jan 24 02:33:47 2025
Change: Fri Jan 24 02:33:47 2025
Birth: Fri Jan 24 02:33:47 2025
➜ ~/temp/testf/tough [2:35:15] exiftool ./binary/go
ExifTool Version Number : 13.14
File Name : go
Directory : ./binary
File Size : 16 MB
File Modification Date/Time : 2025:01:24 02:33:47+05:30
File Access Date/Time : 2025:01:24 02:33:47+05:30
File Inode Change Date/Time : 2025:01:24 02:33:47+05:30
File Permissions : -rwxr-xr-x
File Type : Mach-O executable
File Type Extension :
MIME Type : application/octet-stream
CPU Architecture : 64 bit
CPU Byte Order : Little endian
CPU Type : ARM 64-bit
CPU Subtype : ARM (all) 64-bit
Object File Type : Demand paged executable
Object Flags : Dyld link, Random address
➜ ~/temp/testf/tough [2:35:28]
stat is unable to figure out if a file is binary file or not .
@lazysegtree what do you mean by this?
What information exactly are you missing that is in exiftool? Do you mean "MIME Type"?
@MrPandir FileType
stat gives the same file type for both text and binaries
➜ ~/temp/testf/tough [8:46:45] stat -x 1.txt
File: "1.txt"
Size: 4 FileType: Regular File
Mode: (0644/-rw-r--r--) Uid: ( 501/kuknitin) Gid: ( 20/ staff)
Device: 1,14 Inode: 85629782 Links: 1
Access: Thu Jan 23 12:45:57 2025
Modify: Thu Jan 23 12:45:56 2025
Change: Thu Jan 23 12:45:56 2025
Birth: Thu Jan 23 12:06:34 2025
➜ ~/temp/testf/tough [8:46:56] stat -x binary/go
File: "binary/go"
Size: 16062450 FileType: Regular File
Mode: (0755/-rwxr-xr-x) Uid: ( 501/kuknitin) Gid: ( 20/ staff)
Device: 1,14 Inode: 85816045 Links: 1
Access: Fri Jan 24 02:33:47 2025
Modify: Fri Jan 24 02:33:47 2025
Change: Fri Jan 24 02:33:47 2025
Birth: Fri Jan 24 02:33:47 2025
➜ ~/temp/testf/tough [8:47:02] stat -x binary/go
exiftool can tell the difference, and a whole lot of other information
➜ ~/temp/testf/tough [8:47:02] exiftool 1.txt
ExifTool Version Number : 13.14
File Name : 1.txt
Directory : .
File Size : 4 bytes
File Modification Date/Time : 2025:01:23 12:45:56+05:30
File Access Date/Time : 2025:01:23 12:45:57+05:30
File Inode Change Date/Time : 2025:01:23 12:45:56+05:30
File Permissions : -rw-r--r--
File Type : TXT
File Type Extension : txt
MIME Type : text/plain
MIME Encoding : us-ascii
Newlines : Unix LF
Line Count : 2
Word Count : 2
➜ ~/temp/testf/tough [8:48:27] exiftool binary/go
ExifTool Version Number : 13.14
File Name : go
Directory : binary
File Size : 16 MB
File Modification Date/Time : 2025:01:24 02:33:47+05:30
File Access Date/Time : 2025:01:24 02:33:47+05:30
File Inode Change Date/Time : 2025:01:24 02:33:47+05:30
File Permissions : -rwxr-xr-x
File Type : Mach-O executable
File Type Extension :
MIME Type : application/octet-stream
CPU Architecture : 64 bit
CPU Byte Order : Little endian
CPU Type : ARM 64-bit
CPU Subtype : ARM (all) 64-bit
Object File Type : Demand paged executable
Object Flags : Dyld link, Random address
➜ ~/temp/testf/tough [8:48:31]
@lazysegtree FileType can be obtained from the file command:
⯠file /bin/ls
/bin/ls: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/bin/ls (for architecture x86_64): Mach-O 64-bit executable x86_64
/bin/ls (for architecture arm64e): Mach-O 64-bit executable arm64e
⯠file -I /bin/ls
/bin/ls: application/x-mach-binary
/bin/ls (for architecture x86_64): application/x-mach-binary; charset=binary
/bin/ls (for architecture arm64e): application/x-mach-binary; charset=binary; charset=binary
⯠file /opt/homebrew/opt/[email protected]/libexec/bin/python
/opt/homebrew/opt/[email protected]/libexec/bin/python: Mach-O 64-bit executable arm64
You may want to use man file on mac and on linux, as arguments may not always be present on the two platforms or may not have the same aliases.
@MrPandir Still, exiftool can provide a whole bunch of info you cant get via these tools. Its written for that.
Image file example
â ~/Pictures [8:28:09] file -I W1T-QjML_400x400.jpg
W1T-QjML_400x400.jpg: image/jpeg; charset=binary
â ~/Pictures [8:28:17] file W1T-QjML_400x400.jpg
W1T-QjML_400x400.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, progressive, precision 8, 257x257, components 3
â ~/Pictures [8:28:18] stat -x W1T-QjML_400x400.jpg
File: "W1T-QjML_400x400.jpg"
Size: 17277 FileType: Regular File
Mode: (0644/-rw-r--r--) Uid: ( 501/kuknitin) Gid: ( 20/ staff)
Device: 1,14 Inode: 73230989 Links: 1
Access: Sun Dec 15 09:31:54 2024
Modify: Tue Sep 3 19:22:11 2024
Change: Wed Oct 23 18:13:12 2024
Birth: Tue Sep 3 19:22:11 2024
â ~/Pictures [8:28:31] exiftool W1T-QjML_400x400.jpg
ExifTool Version Number : 13.14
File Name : W1T-QjML_400x400.jpg
Directory : .
File Size : 17 kB
File Modification Date/Time : 2024:09:03 19:22:11+05:30
File Access Date/Time : 2024:12:15 09:31:54+05:30
File Inode Change Date/Time : 2024:10:23 18:13:12+05:30
File Permissions : -rw-r--r--
File Type : JPEG
File Type Extension : jpg
MIME Type : image/jpeg
JFIF Version : 1.01
Resolution Unit : None
X Resolution : 1
Y Resolution : 1
Profile CMM Type : Little CMS
Profile Version : 4.3.0
Profile Class : Display Device Profile
Color Space Data : RGB
Profile Connection Space : XYZ
Profile Date Time : 2017:08:15 00:15:38
Profile File Signature : acsp
Primary Platform : Apple Computer Inc.
CMM Flags : Not Embedded, Independent
Device Manufacturer :
Device Model :
Device Attributes : Reflective, Glossy, Positive, Color
Rendering Intent : Perceptual
Connection Space Illuminant : 0.9642 1 0.82491
Profile Creator : Little CMS
Profile ID : 0
Profile Description : sRGB built-in
Profile Copyright : No copyright, use freely
Media White Point : 0.9642 1 0.82491
Chromatic Adaptation : 1.048 0.02299 -0.05014 0.02971 0.99034 -0.01706 -0.00923 0.01501 0.75226
Red Matrix Column : 0.43585 0.22238 0.01392
Blue Matrix Column : 0.14302 0.06059 0.71384
Green Matrix Column : 0.38533 0.71704 0.09714
Red Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
Green Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
Blue Tone Reproduction Curve : (Binary data 32 bytes, use -b option to extract)
Chromaticity Channels : 3
Chromaticity Colorant : Unknown
Chromaticity Channel 1 : 0.64 0.33
Chromaticity Channel 2 : 0.3 0.60001
Chromaticity Channel 3 : 0.14999 0.06
Image Width : 257
Image Height : 257
Encoding Process : Progressive DCT, Huffman coding
Bits Per Sample : 8
Color Components : 3
Y Cb Cr Sub Sampling : YCbCr4:2:0 (2 2)
Image Size : 257x257
Megapixels : 0.066
â ~/Pictures [8:28:37]
So, what I am thinking right now is that we will start using file and stat for displaying more metadata about files in the default case, when metadata plugin is not enabled (https://superfile.netlify.app/list/plugin-list/)
And we will let users have the option to enable the plugin, install exiftool and and set metadata = true in config - To give them option to be able to see even more info if they want.
@yorukot What do you think about this ?
I can't understand, of course, in what case it would be useful to have all this information in the file manager that you have to scroll through to find the information you need.
In my subjective opinion, the information provided by exiftool is quite redundant. For example, try opening the package.json file, why would I see the dependencies in the metadata when I can open the file in the IDE or vim for that.
If you need more information, you will obviously use a specialized application for that, for photos it's Photoshop, for music it's Audacity, etc.
@lazysegtree Your solution seems optimal to me in this situation. 👌