ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Okay, I can use lsdvd to see what titles and chapters there are on a dvd, easy
I can manually run HandbrakeCLI to process a Title and Chapter
I would like to create a bash script to use the output of lsdvd to loop through that output to run HandbrakeCLI to extract the Title, and optionaly Titles and Chapters, but my beginner skills in bash aren't good enough.
One idea I have is to use lsdvd -C > dvd-structure.txt, then to process that file. But then I get stuck, I'm not sure how to process that file.
I am neither familiar with lsdvd nor HandBrakeCLI but from the lists you posted this may do the job:
Code:
while read t c;do
for (( i=1; i<=c; i++ ));do
echo "Your handbrake with title: '$t' and chapter: '$i'"
done
done < <(lsdvd | awk '{if ($1 ~ "Title"){printf "%d %d\n", $2, $6;}}' )
As you can see it iterates through all the titles with all available chapters. Insert the variables $t and $i into the HandBrakeCLI command as needed. Hope this helps.
I am neither familiar with lsdvd nor HandBrakeCLI but from the lists you posted this may do the job:
Code:
while read t c;do
for (( i=1; i<=c; i++ ));do
echo "Your handbrake with title: '$t' and chapter: '$i'"
done
done < <(lsdvd | awk '{if ($1 ~ "Title"){printf "%d %d\n", $2, $6;}}' )
As you can see it iterates through all the titles with all available chapters. Insert the variables $t and $i into the HandBrakeCLI command as needed. Hope this helps.
I like this, and I think the read line is processing the output of the lsdvd command at the end, so no need for file to hold that output and read later.
while IFS=$'\n' read -d '' -r -a lines
do
TITLE=${lines[1]}
LENGTH=${lines[3]}
echo "${lines[@]}" # does not echo
# do whatever you want
done < dvd.txt
and you still need to handle , (commas).
This reads the entire file and puts an entire line per array element. I cannot echo the array elements inside the loop, in fact, the loop is not entered at all. You can just use a single read to put the entire file into the array:
Some nice answers, some good bash scripts to extend my bash knowledge, but I found a good solution, which I guess could be automated a bit but it works for me
Step 1: use lsdvd to see how many titles on the dvd
Step 2: use vobcopy to extract the titles, this will extract 5 titles
Code:
for i in {1..5};do vobcopy -n $i -t Name-T -v -o .; done
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.