Nautilus Properties – Show Size in Bytes for Multiple Selects and Directories


In Nautilus, the Properties of a single item shows the size as:
a value rounded to one decimal place… nn.n KB, MB, GB…
followed by an exact byte count

For non-single items, Nautilus onlys show a rounded size.

(Single item)   Size:  1.4 GB (1501773824 bytes)

(Multi items)   Size:  5 items, totalling 1.4 GB
(directory)     Size:  5 items, totalling 1.4 GB

Is there some way to make Nautilus display the exact byte count in all situations?

I like the way the Properties dialog allows me to copy this size data, but I usually want to work with the exact size (not an approximation).

Konqueror shows the real size total, but It doesn't allow me to copy the value to to clipboard.

NB: The soluton zerwas provided (below) works nicely, except it reaches an integer maximum of 4,294967,296 bytes (4 GB)…
So for anyone reading this and interested to use this method, here is the ammended code, which caters for a "long long" integer… 9,223,372,036,854,775,807 bytes (8 EB.. E xaBytes).
The first line (/* new */) is at line-number 2337

/* new */   long long ll_total_size = total_size;
/* MOD */   size_str = g_format_size_for_display (ll_total_size);
/* MOD */   text = g_strdup_printf (ngettext("%'d item, with size %s (%lld bytes",
/* MOD */                    "%'d items, totalling %s (%lld bytes)",
/* ASIS */                   total_count),
/* MOD */               total_count, size_str, ll_total_size);

New displayed info:

(Single item)   Size:  1.4 GB (1501773824 bytes)

(Multi items)   Size:  5 items, totalling 1.4 GB (1502027641 bytes)
(directory)     Size:  5 items, totalling 1.4 GB (1502027641 bytes)
(directory)     Size:  188,120 items, totalling 766.8 GB (823295045767 bytes)

Best Answer

The value displayed is called by the function g_format_size_for_display of GLib. You have to edit the source code of nautilus to change this behaviour by just adding an %i to the output:

Step 1: Download source, install dependencies and open the file to edit

mkdir -p .p/nautilus && cd .p/nautilus
sudo apt-get build-dep nautilus
apt-get source nautilus && cd nautilus*
gedit src/file-manager/fm-properties-window.c

Step 2: Change the code

Now go to line 2338 (in Nautilus 2.30) and change with size %s to with size %s (%i Bytes). Do the same for totalling %s. Change it to totalling %s (%i Bytes) It should now look like this:

    text = g_strdup_printf (ngettext("%'d item, with size %s (%i Bytes)",
                     "%'d items, totalling %s (%i Bytes)",

Step 3: Compile

Now you can simply compile Nautilus like every other application

./configure --prefix=/usr
sudo make install
nautilus -q

Note that Nautilus will be overwritten whenever there will be an update to it through package management. This means you have to build and install it again manually.

There is also an alternative way by using an Nautilus script, but this would add another entry in the right click meny instead of having the value in the properties window.