Thursday, August 2, 2012

How to copy a dvd

Here is a simple script that will copy a dvd without having to rip it. This makes a one-to-one copy, so it just reads the bits and doesn't do any resizing or modifying the output format or any of that. It just makes an exact copy of the disk.

#!/bin/bash

# script to copy dvd
# uses readdvd to create an iso from the dvd
# then uses wodim to write iso to a blank dvd disk

# dvd device
dvd_device=/dev/sr0

# temporary file for iso
isofile=/tmp/tmp_dvd.iso

# remove old iso file if it exists
if [ -e "$isofile" ]
then
    rm $isofile   
fi

# read dvd to iso file
readdvd -d $dvd_device -o $isofile

eject $dvd_device

echo "Insert blank disk. Press enter when ready."
read ready

# write iso file to blank dvd
status=`wodim -v -dao dev=$dvd_device $isofile`

if [ "$status" -ne 0 ]
then
    echo "Error writing disk."
fi

# cleanup
if [ -e "$isofile" ]
then
    rm $isofile   
fi

exit

No comments: