.:Hledání:.



kopirovani souboru z cd


Hlasování: 3 (184)   +-


umoznuje zasebou kopirovat nekolik cd/dvd, ktere jsou vzdy ukladany do zvlastnich slozek:

<copy_cd.sh>


#/bin/sh

cdrom=/dev/cdrom
to_dir=/home/data/tmp/cd
cdrom_mount=/mnt/cd
waits=10

counter=0


sudo chmod a+rwx "$to_dir" -R

if [ "$3" != "" ]
then
counter=1
fi


if [ "$2" != "" ]
then
to_dir="$to_dir/$2"
fi

if [ "$1" != "" ]
then
cdrom="$cdrom$1"
cdrom_mount="$cdrom_mount$1"
fi


sudo mkdir "$to_dir" -p
sudo mkdir "$cdrom_mount" -p


t=1
num=0

to_dir_orig="$to_dir"

while [ "$t" != "stop" ]; do

if [ "$counter" -eq 1 ]
then
to_dir="$to_dir_orig/$num"
sudo mkdir "$to_dir" -p
fi

read -t $waits -p "Zacit cist? " t
eject -t $cdrom
sleep 3

if [ "$t" == "stop" ]
then
exit
fi

echo "PRIPOJENI MEDIA"
sudo mount -o iocharset=utf8 $cdrom "$cdrom_mount"
ls "$cdrom_mount"

echo ""
echo "VELIKOST"
du -s "$cdrom_mount"

echo ""
echo "KOPIROVANI"

# kontrola velikosti souboru
for file in "$cdrom_mount"/*; do
f=`basename "$file"`
echo $f
if [ "$f" ]
then
sudo cp "$cdrom_mount/$f" "$to_dir" -R

if [ $? -ne 0 ]; then
echo "del - $to_dir/$f"
sudo rm "$to_dir/$f" -R
fi
fi

done

echo "HOTOVO"

sudo umount $cdrom
echo "ODPOJENO"
# exit

eject $cdrom

#nastaveni opravneni
sudo chown sinker.users "$to_dir" -R
sudo chmod 755 "$to_dir" -R

sleep 1
num=$((num + 1))
echo "zkopirovano $num"
echo ""


beep -f 300.7 -r 1 -d 100 -l 400

done