1

I read before few post with similar title but i can not figure out where is my problem. My bash script stop every time after first line.

#!/bin/bash
#

UUIDFILE=./list

cat $UUIDFILE | while read TITLE
do
        ffmpeg -i ./$TITLE -acodec mp3 -vcodec copy ./$TITLE.mp4
        for file in ./*mkv.mp4; do mv "${file}" "${file//\.mkv/}"; done
        rm -rf ./$TITLE
done

1: Read list of movies form file "list", for example:

Movie.1.2019.mkv

Movie.2.2019.mkv

Movie.3.2018.mkv

2: Convert Movie.1.2019.mkv to mp4

3: Change name

4: Delete mkv movie

5: Again convert another movie from "list" - Movie.2.2019.mkv - Here i have problem because script stop after rm -rf

Sorry for noob question. Best regards.

Andrew541
  • 31
  • 1
  • 1
  • 2
  • BTW, also consider running your code through http://shellcheck.net/ and fixing what it finds. You've got some missing quotes at a minimum (`"$file"` and `"${file}"` are the exact same thing, but `./$TITLE` and `"./$TITLE"` have important differences -- the former won't work when filenames contain spaces). – Charles Duffy Feb 08 '19 at 16:35
  • ...similarly, you should use the `-r` argument in your `while read` loop so it doesn't silently make backslashes in your filenames disappear. See [BashFAQ #1](http://mywiki.wooledge.org/BashFAQ/001) for a full writeup around best practices for using `while read`. – Charles Duffy Feb 08 '19 at 16:35

0 Answers0