Copy in Linux with Ui


The program here is an UI for cp command. I have used cp in the background but over that I am just monitoring the files copied and speed of copying.
It’s not a perfected program. It’s quick one but works fine.
Execution:
Create a file named copy and insert the following code and give execute permission

./copying <source_folder/file> <destination_folder/file>

Code:

#!/bin/bash
orig_size=$( du --max-depth=0 "$1"|cut -f1 )
dest_size=0
speed=100;
speed1=100
i=0;
cp -r "$1" "$2" &
sleep 5
while [ $orig_size -gt $dest_size ] ; do
   temp_size=$dest_size
   dest_size=$( du --max-depth=0 "$2"|cut -f1 )
   if [ $i -eq 10 ]
   then
    speed1=$speed;
    i=0
   fi
   ((i++))
   speed=$((($dest_size-$temp_size)))
   pct=$((( 100 * $dest_size ) / $orig_size ))
if [ $speed1 -eq 0 ] && [ $speed -eq 0 ]
then
eject && orig_size=$dest_size;
fi
if [ $pct -lt 10 ] ; then
   echo -en "b#  $pct% $speed Kb/sbbbbbbbbbbbbbbbbbbbbb"
else
   echo -en "b#  $pct% $speed Kb/sbbbbbbbbbbbbbbbbbbbb"
fi
sleep 1;
done
echo "Copying Over......."

, , , ,

  1. No comments yet.
(will not be published)


  1. Script for Auto Copying of Cds/Dvds | Srijith Unplugged