yego.me
💡 Stop wasting time. Read Youtube instead of watch. Download Chrome Extension

Terminal Lesson 22


3m read
·Nov 3, 2024

Hey guys, this is Macaden on with our 22nd terminal lesson. In this lesson, I'm going to be showing you how to get information about files without having to use a GUI. This is useful if you have to SSH to your Mac from another computer and you can't use other commands to get information about a file that you really need.

So, to do this, we're going to be using the mdimport command, which stands for metadata import. What it does is it reads through a file, reads through some permissions, some attributes, stuff like that, and it gives us information about the file. You can even set how much information you want to get, and I'll get into that in a little bit.

So here on my desktop, I have three different types of files. I have a Pages file, I have an image of an Apple logo here, and I have a video file. I'll just play this; this is a ScreenFlow encoded video file. Um, yeah, so it's like a 5-second little video.

All right, so what we're going to do is we're going to get information about these from the command line. The first thing we're going to do is type mdimport -D and then a space and then a 2 for now. Um, and we'll do testpages.pages to get some information about this.

Don't give us a lot; you can see it's going to tell us a bunch of metadata information. It's going to tell us the type, it's going to tell us the dates and stuff, it's going to tell us the stuff like that, the fonts they're used, and then here it'll tell us at the end the text content. That's pretty cool, I think.

So this actually knows how to read a Pages file. So if you're at school or something and you need to get a Pages file from your Mac, you can mdimport and you'll be able to see the contents. Um, so let's just see if we pipe this into more; obviously, you can read it better.

Um, anyway, let's do mdimport -D1 and see what the difference here is because I want to explain in a second what -D really does. It will give us almost no information, and the reason for that is because -D stands for debug level. The higher it is, the more information you're going to get. So it's one to four; four is a ton of stuff.

You're going to see, um, here let me just pipe it into a file, and you'll be able to look at the contents of this file and see all this stuff. It's really a lot; it'll tell you about all the libraries that's loading and stuff like that, and it's too much. Um, so that's why you can set the amount of information you're going to see.

And anyway, I'll just show you; I mean it's a pretty straightforward command. You can obviously look at the manual page for other things. I'll show you some information about a PNG file. Um, so let's see here; you can see the pixel width, pixels high, the pixel count total, that's just those multiplied, obviously.

Um, the orientation, that's going to be one by default, um, some scales, some information about that, some pretty cool stuff, and I'll do it once again to this movie. And, um, I'll do it to shatter.mov, and if you take a look, you can see the resolution. If we scroll up, you'll see a bunch of information about this.

Um, the encoding application ScreenFlow actually puts itself in there. Uh, here's the display name; it'll have tons of stuff, and it's actually like the codec and stuff used. I think it's pretty useful to be able to get that.

So if we look at the man page here, I'll just take you through a brief look through. You can obviously use plugins; you can, um, do a lot of cool stuff here. You can, um, just get the file schema and exit. There's, um, you can see a bunch of different stuff. Here's the -D, obviously, which is the debug level.

Um, and yeah, so basically that's pretty much it. mdimport it's a pretty cool command. I've used it multiple times from school where I want to get contents of a Pages file, and it's quite useful.

So anyway, thanks for watching, kids, and subscribe, and goodbye.

More Articles

View All
Why The War on Drugs Is a Huge Failure
Over 40 years ago, US President Richard Nixon declared drug abuse public enemy number one, starting an unprecedented global campaign, the War on Drugs. Today, the numbers are in. The War on Drugs is a huge failure, with devastating unintended consequences…
Rational Optimism Is the Way Out
In general, professions in which you get your feedback from other members of that profession tend to get corrupted. When you see a journalist writing articles to impress other journalists, or a restauranteur running a restaurant that’s designed to impress…
Warren Littlefield: Television Audiences Will Find Great Content, Wherever It Is | Big Think
Warren Littlefield: In Must See TV through the ‘90s, it was an incredible time where one network, one night, for one decade a third of the country watched NBC. They wanted to be a part of the national conversation or don’t go to work the next day. You’d b…
A Conversation with Aileen Lee - Moderated by Geoff Ralston
Today I am honored to have my good friend Aileen Lee here, and we’re going to have a conversation about stuff. Yeah, well, I hope we talk about like aliens. Aileen is a very public personality in the venture world, so there’s lots of great talks she has g…
Meet the Intimidating Eel That Mates For Life | National Geographic
Okay, so this is a wool feel. As anything named after a wolf would suggest, they are intimidating master predators. You may see the way this guy chomps down on a sea urchin like it just doesn’t even feel its spines on its throat. His teeth are pretty worn…
Safari Live - Day 114 | National Geographic
And welcome to you from myself, Steve Falconbridge, joined by Fergus on camera. We are out in Toomer, in Sabi Sands, with degrees of 33 degrees Celsius and 89 degrees Fahrenheit. It is a nice warm day; the Sun is beating down. We have developed a bit of a…