#!/usr/bin/env bash # CD Ripper (GNU/Linux version) # Given an a batch-ripping CD drive, like the Kodak KDK-1000-04, this # script will rip all CDs to raw PCM data. # # Requires "cdtool" for detecting if a CD is in the drive using `cdir`, # "eject" for ejecting and closing the drive, and "cdparanoia" for # ripping the audio tracks off a CD script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd_drive_optical="/dev/sr2" # Change this to your CD drive cd_drive_serial="/dev/ttyUSB0" function grabcd { echo -n 'A' > "$cd_drive_serial" `# Open the arms` \ && sleep 1 \ && eject "$cd_drive_optical" `# Open the drive` \ && echo -n 'G' > "$cd_drive_serial" `# Lift the disk` \ && sleep 1 \ && eject -t "$cd_drive_optical" `# Close the drive` \ && echo -n 'A' > "$cd_drive_serial" `# Drop the disk` \ && sleep 1 \ && echo -n 'G' > "$cd_drive_serial" `# Ready arms for CD` \ && sleep 1 \ && echo -n 'I' > "$cd_drive_serial" `# Push CD into the arms` \ && sleep 1 \ && eject "$cd_drive_optical" `# Open the drive` \ && echo -n 'A' > "$cd_drive_serial" `# Lower CD into drive` \ && sleep 1 \ && eject -t "$cd_drive_optical" `# Close the drive` \ && sleep 10 \ && cdir -d $cd_drive_optical | grep -q "tracks" # Check for CD } function ripcd { cdparanoia \ --log-summary="cdparanoia.log" \ --stderr-progress \ --force-cdrom-big-endian \ --output-raw \ --output-raw-little-endian \ --batch \ --never-skip=20 \ --force-cdrom-device "$cd_drive_optical" \ 1- } while grabcd do # If there are already CDs ripped in this directory, don't overwrite # existing ones. index=`ls 2>/dev/null | grep 'ripped-' | sort -t '-' -k 2 -g | tail -n 1 | awk '{print $NF}' | awk -F '-' '{print $2}'` if [[ "" == "$index" ]] then index="0" fi cd_out="ripped-$(($index+1))" mkdir "$cd_out" && cd "$cd_out" && ripcd && cd .. done