LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-30-2018, 11:11 PM   #1
ruben1910
LQ Newbie
 
Registered: Jul 2018
Posts: 17

Rep: Reputation: Disabled
DD command with label of dvd


Hello Everybody

I want a script that copy a dvd to an iso file.
This is what I got.

Code:
eject -t /dev/sr0 &&

sleep 30 &&

blkid -s LABEL -o value /dev/sr0 &&

# copy dvd to a location on my pc
dd if=/dev/sr0 of=/home/gebruiker/Bureaublad/LABEL.iso &&

rename 's/oldname/newname' *.iso $LABEL.iso &&

# eject drive
eject /dev/sr0
The problem is that I can't get automatically the label of the dvd in the name of the iso file.

How can I fix this?

Kind regards
Ruben
 
Old 07-30-2018, 11:35 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
Things don't happen by magic, you need to create the variable. Something like this might work.
Quote:
Originally Posted by ruben1910 View Post
LABEL=$(blkid -s LABEL -o value /dev/sr0) &&

# copy dvd to a location on my pc
dd if=/dev/sr0 of=/home/gebruiker/Bureaublad/$LABEL.iso &&
 
1 members found this post helpful.
Old 07-30-2018, 11:56 PM   #3
ruben1910
LQ Newbie
 
Registered: Jul 2018
Posts: 17

Original Poster
Rep: Reputation: Disabled
There are some interspaces in the dvd name.
That's a problem for the script
 
Old 07-31-2018, 12:38 AM   #4
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,128

Rep: Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121Reputation: 4121
So get rid of them - simplest would be to pipe the blkid output into tr; underscore is a viable alternative to a blank. Then your $LABEL is correct without further processing. You can avoid the word splitting with quotes, but there is always a "corner case" where it gets ugly.
 
1 members found this post helpful.
  


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
Shell - command to get the DVD disk label ankit_mcgill Linux - Newbie 6 09-24-2007 03:25 PM
Getting the label name of a cd/dvd TomG22 Linux - Software 3 05-14-2007 04:59 PM
Any CD/DVD label software for linux ? Christof999 Linux - Software 1 10-05-2006 06:59 PM
Linux command to get the DVD label? jrfk2 Linux - General 7 01-15-2006 08:39 AM
How can I display the label of a DVD? klausabc Linux - General 0 09-26-2004 08:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:27 PM.

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