LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-24-2011, 03:23 PM   #1
valunthar
LQ Newbie
 
Registered: Jun 2011
Posts: 10

Rep: Reputation: Disabled
Best way to automatically copy files off of a cd to a specific folder?


What would be the best way to automatically copy all of the data off of a library of cds to a specific folder on the computer? I was thinking of running a bash script but I've run into a few snags figuring out the correct way to do it. Mainly due to the fact that the cd drive is mounted in a different folder in /media each time I insert a new disk. Also, the mounting and unmounting process causes it's own problems, but I think that could be covered by a for loop that checks /mtab every few seconds or so.

Any help in figuring this out would be greatly appreciated.

Last edited by valunthar; 06-24-2011 at 03:28 PM.
 
Old 06-24-2011, 04:44 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Hi there,

Give these steps a try:

1. vi /cdcopy
2. Put the following lines in the file:

mkdir /media/cddrive
mount /dev/cdrom /media/cddrive
cp -arv /media/cddrive/. /location_where_you_want_files_to_be_copied
umount /media/cddrive
rm -r -f /media/cddrive

3. After putting the above lines save the file and exit.
4. Change the permissions on the file to make it executable. chmod 777 /cdcopy
5. Whenever you want to execute the file, execute using ./cdcopy

I hope this helps.
 
Old 06-24-2011, 05:27 PM   #3
valunthar
LQ Newbie
 
Registered: Jun 2011
Posts: 10

Original Poster
Rep: Reputation: Disabled
hmm, that does look promising, though I think would do something like this instead

if `cat /dev/mtab | grep /dev/sr0` = true
umount /dev/sr0
mount /dev/sr0 /media/cddrive
cp -arv /media/cddrive/. /Archive
echo "The CD has finished copying"
umount /dev/sr0
end if

Though I'm not completely certain whether that if condition would actually work in bash as currently written. Now the only thing left to figure out is to get the script to automatically run whenever a disc is inserted. A possible solution would be polling mtab, but I'm not quite sure how to go about doing it. Also, some kind of gtk notification and ejecting the cd-rom tray when it's finished copying would be useful additions.

EDIT: Now this is weird, I tried that script without the if portion and things seemed to copy properly, except for the fact that all of the files copied had invalid encoding appended to the file name. Any ideas on why that happened?

Last edited by valunthar; 06-24-2011 at 05:48 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a way to automatically copy an flashdrive to a predetermined folder? sc4s2cg Linux - Newbie 1 02-13-2011 01:14 PM
rsync to copy specific files kilee Linux - Newbie 4 01-15-2011 08:23 AM
i need to copy files from one folder to another folder using shell anurupr Linux - Newbie 17 03-04-2010 09:07 AM
Automatically set permissions of new files created within a specific folder Lorian Linux - Desktop 2 03-03-2007 03:17 PM
How to automatically move files from one folder into another folder? xmrkite Linux - Software 6 11-05-2006 10:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration