DVD Batch Copying
I needed to copy a lot of files from a lot of DVDs over to a local hard-drive. In order to help with this, I made a shell script to semi-automate the process. This script will eject the tray, wait for the user to press enter, then close the tray and start copying files. After it is done copying, the process loops, asking for the next DVD to be put in the tray.
Here it is, hope you can make use of it:
#!/bin/bash
function abort {
echo "Aborting..."
eject -t /dev/cdrom
exit
}
trap abort SIGINT
# Find first available directory.
DVD_NO=1
while [ -d "./dvd_$DVD_NO" ]; do
DVD_NO=`expr $DVD_NO + 1`
done
while /bin/true; do
eject /dev/cdrom
# Wait for user to press enter.
while /bin/true; do
echo -n "Feed me! "
read -n 1 CHAR
if [ "$CHAR" == "" ]; then
break
fi
done
eject -t /dev/cdrom
echo "Reading DVD #$DVD_NO..."
sleep 30
mkdir -v "./dvd_$DVD_NO" || exit 1
mount /mnt/cdrom || exit 2
cp -v -R /mnt/cdrom/* "./dvd_$DVD_NO"
find "./dvd_$DVD_NO" -type d -exec chmod 755 {} \;
find "./dvd_$DVD_NO" -type f -exec chmod 644 {} \;
sleep 3
umount /mnt/cdrom
sleep 3
DVD_NO=`expr $DVD_NO + 1`
done