#!/bin/bash # # Info-Size -> (Calcul the total size from selection (with multiple selection)) # # Owner : Largey Patrick Switzerland # patrick.largey@nazeman.org # www.nazeman.org # # Licence : GNU GPL # # Copyright (C) (Owner) # # Dependency : gdialog (gnome-utils) or zenity # : Nautilus # # Encoding UTF-8 # # Ver. 1.1 13.12.2003 # add compatibility with zenity # # Vers.: 1.00 02.05.2003 curpath=`echo $NAUTILUS_SCRIPT_CURRENT_URI | sed 's/file\:\/\///'` cd $curpath # # lang variable # title="Total size" selection="The selection have" bytes="bytes" kilo="kilo-bytes" mega="mega-bytes" giga="giga-bytes" case $LANG in fr* ) title="Taille total" selection="La sélection fait" bytes="octets" kilo="kilo-octets" mega="mega-octets" giga="giga-octets";; esac # # Count in kilo pro file and directory # mid=0 while [ $# -gt 0 ] do a=`ls -lR "$1" | grep "^-" | gawk '{ print $5" +" }'` a="$a 0" countsize=`echo $a | bc` mid=$(($countsize + mid)) shift done calc=`echo $mid | wc -c ` if [ $calc -le 4 ] then totalinfo="$selection $mid $bytes" elif [ $calc -le 7 ] then mid=$(echo "scale=2; $mid / 1024" | bc) totalinfo="$selection $mid $kilo" elif [ $calc -le 10 ] then mid=$(echo "scale=2; $mid / 1048576" | bc) totalinfo="$selection $mid $mega" else mid=$(echo "scale=2; $mid / 1073741824" | bc) totalinfo="$selection $mid $giga" fi if which zenity 2>/dev/null then zenity --title "$title" --info --text "$totalinfo" else gdialog --title "$title" --msgbox "$totalinfo" 100 100 fi