Quantcast
Channel: Sriunplugged » Search Results » rhel-setup-cd-repo
Viewing all articles
Browse latest Browse all 13

Script for Auto Copying of Cds/Dvds

$
0
0

Here is a script that i created for automatically copying all the files in cd to a folder and ejecting and waiting for the next cd.
So here is how it works.
You need to change the folder names and paths accordingly. And the shell script as

./cdcopy

This script depends on the copy Script I posted earlier so use that as well.
On starting the script checks for cd in the drive . If not it waits for cd. On inserting the cd/dvd the script copies the contents of the cd into a new folder with the cd label into the specific folder. And it ejects the cd once it finishes the copying.
So that’s all try it out and tell me how it goes.

#!/bin/bash
while [ 1 ]
do
if [ $(du --max-depth=0 /media/cdrom0|cut -f1) -gt 4 ]
then
echo "Cd Drive Found"
fname=`volname /dev/cdrom`
echo -e  $fname" Found.\nStarting  to copy.."
flag=0
i=0;
orgfname=$fname;
while [ $flag -eq 0 ]
do
if [ -d "/media/disk-1/Music/`echo $fname`" ]
then
((i++))
 fname=$orgfname-$i
 else
 flag=1
fi
done
echo "Folder Name: "$fname
 ./copy "/media/cdrom0" "/media/disk-1/Music/`echo $fname`"
 eject
 echo -e "Cd Ejected.\nInsert next Cd"
 sleep 15
else
 echo "Waiting For Cd"
 sleep 15;
fi
done


Viewing all articles
Browse latest Browse all 13

Trending Articles