Copiar CD's y DVD's
Nombre: cpycd
Autor: Luis Moreno Rodriguez
Lenguaje: Bash
Licencia: GPL
Dependencias: cdrecord ó wodim
Hace todas las copias que quiera el usuario de un CD o de un DVD.
cpycd
#!/bin/bash
# AUTOR: Luis Moreno Rodriguez 2010
function cpycd () {
# CD ROM device
CDROM=/dev/sr0
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo -e "Make cd copies from data cd. Usage 'cpycd'"
return
fi
if ! ls $CDROM &>/dev/null; then
echo -e "ERROR! the device $CDROM doesn't exists, adjust CDROM variable in the script."
return
fi
OF=/tmp/cdimage_cpycd.$$.iso
BLOCKSIZE=2048
# SPEED=10 # If unspecified, uses max spd.
DEVICE="1,0,0"
echo; echo "Insert source CD, but do *not* mount it."
echo "Press ENTER when ready. "
read
eject -t $CDROM &>/dev/null
echo -n "Copying the source CD to $OF."
echo "This may take a while. Please be patient."
dd if=$CDROM of=$OF bs=$BLOCKSIZE # Raw device copy.
eject $CDROM &>/dev/null
local OPTION="y"
local NUM_COPY=0
while [ "$OPTION" = "y" ] || [ "$OPTION" = "Y" ]; do
echo -e "\nRemove data CD and insert blank CD-R."
echo "Press ENTER when ready."
read
eject -t $CDROM &>/dev/null
NUM_COPY=`expr $NUM_COPY + 1`
echo "Copying $OF to CD-R (copy $NUM_COPY)."
if which wodim &>/dev/null; then
if ! wodim -v -isosize dev=$DEVICE $OF; then
echo -e "ERROR! check the blank CD-R."
fi
else
if ! cdrecord -v -isosize dev=$CDROM $OF; then # speed=$SPEED
echo -e "ERROR! check the blank CD-R, and that you have installed wodim or cdrecord."
fi
fi
# Uses Joerg Schilling's "cdrecord" package (see its docs).
# http://www.fokus.gmd.de/nthp/employees/schilling/cdrecord.html
# Newer Linux distros may use "wodim" rather than "cdrecord" ...
echo -e "\nDone copying $OF to CD-R on device $CDROM (copy $NUM_COPY)."
eject $CDROM &>/dev/null
echo "You want to do other copy? [y]es [N]o: "
read OPTION
done
rm $OF
}
cpycd