- # Move the created MKV file into place
- echo -e "\n Moving $dstdir/*.mkv -> $dstmkv"
- mv "$dstdir"/*.mkv "$dstmkv"
+ if [ $makemkv_copy_largest_title_only -eq 1 ]; then
+ # Move the largest created MKV file to destination
+ # There might be multiple ones, so just grab the largest one
+ largest_mkv_file=`/bin/ls -1S "$dstdir"/*.mkv | head -1`
+ echo -e "\n Moving largest mkv file $largest_mkv_file -> $dstmkv\n" | tee -a "$ddrescuelog"
+ mv "$largest_mkv_file" "$dstmkv"
+ else
+ # Move all of the created MKV files to destination
+ echo "\n" | tee -a "$ddrescuelog"
+ dstfile=${dstmkv%.[^.]*}
+ typeset -i num=0
+ typeset -i titles=0
+ for i in `/bin/ls -1 "$dstdir"/*.mkv`; do
+ ((titles = titles + 1))
+ done
+ if [[ $titles > 1 ]]; then
+ for i in `/bin/ls -1 "$dstdir"/*.mkv`; do
+ echo -e " Moving $i -> $dstfile.$num.mkv" | tee -a "$ddrescuelog"
+ mv "$i" "$dstfile.$num.mkv"
+ ((num = num + 1 ))
+ done
+ else
+ echo -e " Moving $dstdir/*.mkv -> $dstfile.mkv" | tee -a "$ddrescuelog"
+ mv "$dstdir"/*.mkv "$dstfile.mkv"
+ fi
+ echo "\n" | tee -a "$ddrescuelog"
+ fi
+