File Size Counters and Actual File Size for Linux

Tags: thunar custom actions, zenity, filesize
November 11, 2015

To learn how to use Thunar Custom Actions click here.

##Counter

This custom action will display the size of each selected file/folder in a pop-up window. The program Zenity must be installed for this action to work.

File Size Counter - Thunar Custom Action

du -chs --apparent-size %N | zenity --text-info

Under Appears if selection contains make sure everything is checked.

##Report ACTUAL file size for Thunar

The program Zenity must be installed for this action to work.

Thunar has a strange weakness when it comes to reporting file sizes.

Thunar is reporting the MiB of the file as the number of KiB/1000, which is the method that hard drive manufacturers use to dupe us into believing we’re getting a larger hard drive than we actually get. Read more about the problem here.

This works on files, but YMMV on folders. It’s supposed to work on folders, but the results are screwy.

File Size Counter - Thunar Custom Action

/home/$USER/Scripts/file-size.sh %N

Under Appears if selection contains make sure everything is checked.

###Bash Script

I keep my bash scripts in a folder called “Scripts” in my personal directory. To create the bash script copy the script below and paste it into a text editor. Name the script file-size.sh and save it to the scripts folder you created. Make the script executable by opening up a terminal and navigating to the folder in which the script is stored. Type chmod +x file-size.sh and press Enter. The script will now work when used with Thunar Custom Actions.

Bash Script

}