Register
It is currently Thu Nov 20, 2014 8:26 pm

Automatically copy CDs to hard drive


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Mar 11, 2008 6:36 am   

Joined: Tue Mar 11, 2008 6:32 am
Posts: 2
I would like a script that copies the contents of a CD to a directory named with the label of the cd (from volname). All CDs are copied to the same parent directory (/media/Media/CDs/) and each cd is copied into a subdirectory (/media/Media/CDs/cd1/)
After the cd is read in, the cd tray should eject, and wait for another cd to be manually inserted
After another cd is inserted, the process repeats until a keyboard button is pressed to exit the script

Sounds simple enough? I started to write it but after the first cd ejects, there seems to be a problem getting the next cd to read (says there are no files in the cd and ejects the cd without reading anything.

Thanks!


Top
 Profile  
 PostPosted: Thu Mar 13, 2008 9:43 am   
Site Admin

Joined: Tue May 17, 2005 7:31 pm
Posts: 251
Location: Georgia
please post what you have so far... it would be a waste for someone to write the script themselves if you already have a nice head start :wink:


Top
 Profile  
 PostPosted: Thu Mar 13, 2008 5:28 pm   

Joined: Tue Mar 11, 2008 6:32 am
Posts: 2
#!/bin/bash
source="/media/cdrom"
dest="/home/grant/Desktop/tmp"
#dest="/media/Media2/Video"
cd="/dev/cdrom"
continue=""
quit="q"

until [ "$continue" == "$quit" ]; do
label=""
# get the label of the cd
while [ "$label" == "" ]; do
label=`volname $cd`

# remove any trailing spaces (there's always spaces at the end)
label=$(echo $label | sed 's/ *$//')

# if no label, then wait for 5 seconds
if [ "$label" == "" ]; then
sleep 5
fi
done

echo "Found cd labeled '$label'"
echo "Copying to '$dest/$label'"

mkdir "$dest/$label"
cd "$source"
ll
cp -vr --no-preserve=mode * "$dest/$label/"
chmod 755 "$dest/$label/*"
cd ~
eject

# prompt to continue or stop
#echo "Press enter to read next disk, q to quit"
#read continue

# if continuing to read next disk
#if [ "$continue" != "$quit" ]; then
# insert the cd tray
#eject -t
#fi
done


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP