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

Another Way Finder Tricks You


5m read
·Nov 3, 2024

Hey guys, this is Matt Headson one with a video on something that's kind of confusing that not a lot of Mac users know about, and this is resource forks.

So, uh, I'll jump right into it. If you've ever noticed when you created a text clipping on your desktop or something like that, that the file actually has no data in it. Let me just give you an example. We'll just select some text in my terminal and drag it onto my desktop, and here it is.

Um, so you can see right here that when we preview it or look at it with Quick Look or whatever, that it says "Alex Nichols MacBook Pro." Um, but what you might be wondering is, well, where's this data actually stored? And you can double-click it with Finder and it'll bring up this little window. It doesn't leave the app or anything, and it says the contents. But, you know, even, even uh, Finder itself says it's a certain amount of bytes.

But if we use Terminal real quick and we just vi this file, it's zero bytes and zero lines, obviously. And now it's ls ellit, and right there you can see the size is zero. And that is because on HFS Plus, which is, you know, the Mac file system basically, there is another place where data can be stored other than the data fork of a file. This is called a resource fork.

So now, files have multiple places to store data. There are a bunch of other forks too, I think. But in order to see the complete information, we do ls l at sign, and I put the a there. Um, and then you can give it a file and it'll say there's a resource fork. There's a, you know, and so you might be wondering then, well, if this file has a resource fork, then where's the actual data? How do we get to that resource fork, and how do we view that resource fork?

The answer is that there's no real way to do that that's built into Terminal or whatever. They're obviously, it's pretty easy to do with programming and stuff. Another thing to note is that if you ever zip a text clipping and send it to someone with a PC, it creates a dot underscore file.

Um, and that is the resource fork actually. That's how it's stored in non-HFS Plus volumes because there's a Mac OS 10 file system specific thing. Anyway, um, because I wanted to do a little research on this and, you know, I wanted to get more information than just that, I made a couple apps that read resource forks of files and do stuff with them.

The first one is this one, and I'll be posting this source code. Um, I think I already put it on Git, and I'll have a link for the Git project in the description. But anyway, here it is. I'll build it. It's a small GUI app that will give you the data stored in a resource fork.

There's going to be a lot of bogus data in this because, obviously, this is a text clipping, and it's not just text because you can have rich text as well. It's got a lot of metadata stored in that file as well, so uh, you're gonna see a lot of junk. You can see there's some header information, then there's the text. It's there multiple times just because that's how their format works.

Um, and then there's more junk. I can change the contents of this resource fork; I'll make it say "Alex was here." And if I click save, this will no longer be a valid text clipping because I changed the resource fork. So, as you can see, it is uh, no longer valid, and it says 14 bytes because it's giving us the size of the resource fork now.

That, because Finder is smart enough to do that. And I can obviously drag in whatever I want. Um, I'll create a file called foo, and I'll say "this is a file," and it'll have a file here with data in it, right? If I drag it in, there's no resource fork, so let's make it say "Alex wasn't here."

Save that, and we can look back at the resource fork of this text clipping. Now it says "Alex was here," and the resource fork of foo.txt says "Alex wasn't here." So that's pretty much all this app does; it's basically it. It reads and writes to resource forks.

Um, it doesn't do special characters; it only does ASCII. So if you load one of a real text clipping and change it and then save it, it won't work. Um, anyway, that is how to read basic resource forks and read the data out of resource forks.

I'm also gonna, I made a command line application that reads text clippings. So let's create a text clipping. I'll make a textbook.finder info. Alright, and I'll make a rich text clipping of my little return type here in my Expo project.

And so this is rich text, as you can see, and this is plain text. So I'll just launch my command line application called text clipping reader that I made, and this is already on Git. I'll have the link; you can drag it in here and you pass it a file. And I'm giving it the Finder info textbooking. So that's what's in it, and right here it'll output the plain text of what's in the text clipping.

So it actually knows what the format of the text clipping is, and it reads through it and processes it. And I did have to reverse engineer that, but, um, it wasn't as difficult as it might seem.

Um, you can also load rich text, except, um, I'm gonna have to drag this file in. You can load rich text; it'll give you the RTF file here. There's gonna be an extreme pain here; let me rename this rich text. Alright, it'll give you the RTF contents basically. So here's the RTF contents of this file, and if you vi food.rtf and you paste it in here, you'll have a valid RTF.

So you can take what's in this and convert it to an RTF. You can also get the plain text if you're not an RTF guy by doing the --plain, and then it's rich text, and I'll just give you this.

So I've made this terminal command. Um, this is mainly for people who are just kind of interested in resource forks. Um, obviously, I'm not gonna show you how to install any of this stuff or anything because I assume that you'll know how to use Xcode enough to do that yourself, um, and stuff like that.

Anyway, these are just, uh, it's interesting to see how resource forks work. Apple doesn't suggest ever using these; they suggest just keeping all your information in the regular data of a file. But I don't know how they could suggest you do that when they, in their text clippings, and I think they do it with web block files too.

I don't know, web location files, um, they might do it as well where the file has no actual contents. So, um, whatever. This is pretty cool. Um, check it out in the description; I'll have a link to both Git projects.

So anyway, subscribe and goodbye.

More Articles

View All
Jacksonian Democracy part 2
So we’ve been talking about the emergence of Jacksonian Democracy in the first half of the 19th century in the United States. We’ve been talking about how, in this time period, the vote was slowly extended to all white male citizens so that by the end of …
How Does The James Webb Space Telescope Work? - Smarter Every Day 262
This is my dad, and he’s about to finish this major job you’ve been working on, which is the James Webb Space Telescope? Sun shield for the James Webb Space Telescope. Hey, it’s me, Destin, welcome back to Smarter Every Day. The James Webb Space Telescope…
The BEST ways to invest your first $1000
What’s up you guys? It’s Graham here. So this has got to be one of my most requested videos, especially for people that are just starting out or don’t have a lot of money saved up. That is how to invest your first $1,000. This amount, when you’re just st…
Fairness is a universal value. So why all this inequity? | Dr. Monica Sharma | Big Think
We’ve generally worked on problems by looking at how can we solve the problem. But that’s very much a fix-it mindset. Here’s a problem, and what can we do to solve it? And technology, advances in technology, have enabled us to do that. And is that importa…
EconTalk Host Russ Roberts on Key Economic Concepts for Founders
Russ Roberts: Welcome to the podcast! Hey, correct, great to be here! So, you, for those who don’t know, are the host of EconTalk, a research fellow at Stanford’s Hoover Institution, and the author of several books including “How Adam Smith Can Change Yo…
How farming planted seeds for the Internet - Patricia Russac
Transcriber: Andrea McDonough Reviewer: Bedirhan Cinar We talk about inventions and innovation as though the best things out there are the Internet, iPads, or smartphones. Or perhaps more simply, trains, planes, and automobiles. Which one is most importa…