filesystem

Scala code to find (and move or remove) duplicate files

My MacBook recently told me I was running out of disk space. I knew that the way I was backing up my iPhone was resulting in me having multiple copies of photos and videos, so I finally decided to fix that problem by getting rid of all of the duplicate copies of those files.

So I wrote a little Scala program to find all the duplicates and move them to another location, where I could check them before deleting them. The short story is that I started with over 28,000 photos and videos, and the code shown below helped me find nearly 5,000 duplicate photos and videos under my ~/Pictures directory that were taking up over 18GB of storage space. (Put another way, deleting those files saved me 18GB of storage.)

How to easily determine the blocksize of a filesystem

I just saw that this is a way you can easily determine the blocksize of a filesystem, at least a Mac/Unix/Linux filesystem:

$ echo foo > foo

$ du -h foo
4.0K    foo

I tried to do the same thing with touch foo, but that didn’t work. Without digging into it more, the key seems to be in having very little text in the file, at which point the du command shows the minimum block size for the file.

How to copy files to an Android emulator’s data directory with ‘adb push’

As an Android developer, you can normally use the adb push command to copy files from your computer’s hard drive to an Android device. However, I just ran into a problem where I couldn’t copy files to my Android emulator’s “data” directory, i.e., the /data/data filesystem. When I tried to copy a file using this command:

$ adb push foo.jpg /data/data/com.alvinalexander.myapp/files

I got this Android error:

Those Mac .DS_Store files

Mac .DS_Store files FAQ: What are these .DS_Store files on my Mac, and how can I get rid of them?

Those crazy Mac .DS_Store files (also referred to as "dsstore" files) finally got to me, so I did some research on where they come from, and how to get rid of them (or more accurately, how you can't get rid of them).

Here's what I've learned about Mac OS X .DS_Store files.

How to show the full path to the current Finder folder

So, you're sitting there, looking at your Mac Finder window, and you see the file you need to work with, but wait ... what is the path to the directory you're looking at?

The Finder is a clever interface -- especially now that it sports four different views -- but at times like this, it just leaves you hanging. I run into this problem all the time when I go to upload a file using any of my web-based email clients, or when I upload a file using a web form.

A Ruby temporary file example

Problem: There are times when you're writing Ruby code that you need to be able to create and write information to a temporary file. If you write your own code to do this, there are a number of decisions to be made (see below), and you'd like to avoid all of that mess.

Solution: Use the Ruby Tempfile class to handle the grunt work for you.

Use the Linux df command to show free disk space

Linux free disk space FAQ: How do I show free disk space on a Unix or Linux system?

The Linux df command stands for "disk free". It is meant to show Linux disk space information, including disk space that is used, disk space remaining, and how filesystems are mounted on your Linux (or Unix) system. The Linux df command not only shows the free disk space on your local computer, it also shows the free disk space on all networked filesystems that are mounted by your Linux system.

A Mac Olympus DS-30 review

Mac Olympus DS-30 review: Here's my quick take on the Olympus DS-30, from the perspective of a Mac user.

If anyone is looking at an Olympus DS-30 voice recorder, and wondering if it will work with Mac OS X (in particular for making podcasts), the answer is both yes and no (with a little extra emphasis on the "no").

A tag-based filesystem

After working with del.icio.us and other tag-based systems, and thinking about adding tag support and other features to this blog, I started wondering if anyone had applied the "tag" concept to any other systems that are typically directory-based (as del.icio.us seems like a very good replacement for a traditional hierarchical organization (directory) of bookmarks).