You are Here:
Linux Lite 7.0 RC1 Released - See Release Announcement Section

Windows-like file size info

Author (Read 8816 times)

0 Members and 1 Guest are viewing this topic.

Windows-like file size info
« Reply #1 on: November 27, 2014, 10:35:44 PM »


  • Muted
  • Gold Level Poster
  • *
  • 688
  • Reputation: 192
  • Linux Lite Member
    • View Profile

  • CPU: Dual core Pentium E5700 3GHz

  • MEMORY: 3Gb

  • VIDEO CARD: GeForce GT 430
First let's make it clear
    "1 KB" means 1024 bytes (as Windows would report it, traditional usage)
    "1 KB" means 1000 bytes (as Linux would report it, IEC usage)
    "1 KiB" means 1024 bytes (unambiguous, but perhaps unfamiliar terminology, IEC usage)
This is why, in Windows:
1 Terabyte hard drive is only 932 Gibabytes
CD filesize is 700 MB
and DVD isn't     4.7 GB

This script displays file sizes as Windows would.
You can select multiple files and with a right-click and call the Thunar Custom Action which is going to call this script.
It will not work with Directories.

Directions are in the script.
Code: [Select]
>/tmp/1024conv; >/tmp/1024convR;for file in %N; do echo "$file" >> /tmp/1024conv ;done; /usr/bin/1024convert  %N
Code: [Select]
# Thunar custom action to calculate and display file sizes in Kib, MiB and Gib in a zenity list dialog
# Command for the thunar custom action:
# >/tmp/1024conv; >/tmp/1024convR;for file in %N; do echo "$file" >> /tmp/1024conv ;done; /usr/bin/1024convert  %N
# This file should be saved in /usr/bin and named 1024convert
# and made executable (chmod +x)
# Mark all file types except directories
# File pattern *
# Cheers from Misko

# Calculate File Sizes in Kib, MiB and Gib and write the results in /tmp/1024convR
stat -c%s "$@" |
awk '{


for (x=1024**3; x>=1024; x/=1024)
if (sum>=x)
  printf "%.2f %s\n",sum/x,hum[x];
if (sum<1024)
printf sum" bytes\n";
}' > /tmp/1024convR

# store the file list

# Merge the results from two files and display the result
paste -d'\n' /tmp/1024conv /tmp/1024convR > $list

# clear our array

# read in the array using a line tmp variable. This let's zenity see it line by line
while read -r line
done < /tmp/1024list

zenity --list --column=Name --column=Size "${LIST_Z[@]}" --width=800 --height=700 --title="1024 byte conversion" --text="File size displayed in the IEC standard"
# Remove temporary files
rm /tmp/1024list
rm /tmp/1024conv
rm /tmp/1024convR

Windows-like file size info... Yeah, I know :)
Spent my creativity on the scipt.


X Close Ad

Linux Lite 7.0 RC1 Released - See Release Announcement Section