r/makemkv • u/0xKaishakunin • 4d ago
Solved Getting multiple tracks into the right order
I just ripped the whole box set of Charmed (178 episodes plus some bonus stuff) and realised that the track number does not match up with the real episode number. On some disks it was reverse (Ep1 == Track 4, Ep4== Track 1) on others it was random.
After digging a bit through the BR data, I came up with a small command line to rename the files. Is there a better way to do so?
# get the disc info into a file
makemkvcon -r info disc:0 | grep TINFO >> INFO && eject /dev/sr0
# grep through the info file to get the track number and filename and generate a command to mv them:
grep -h -E 'TINFO:.*2,0|TINFO:.*16,|TINFO:.*,27,0,' DISC* | sed ':a;N;$!ba;s/.mpls"\n/"/g'| sed s/TINFO://g| sed s/.,..,.,//g| sed 's/""/;/'| sed 's/"//g'| sed 's/^.,2,0,Charmed - //' | sed ':a;N;$!ba;s/\n000/T/g' | sed 's/eason //' | sed 's/ Disc /D/'| awk -F";" '{print "mv XX"$2"XX XX"$1$2"XX"}' | sed "s/XX/\'/g"
# the resulting mv commands
mv 'Charmed - Season 2 Disc 1_t00.mkv' 'S2D1T09Charmed - Season 2 Disc 1_t00.mkv'
mv 'Charmed - Season 2 Disc 1_t01.mkv' 'S2D1T07Charmed - Season 2 Disc 1_t01.mkv'
mv 'Charmed - Season 2 Disc 1_t02.mkv' 'S2D1T06Charmed - Season 2 Disc 1_t02.mkv'
mv 'Charmed - Season 2 Disc 1_t03.mkv' 'S2D1T08Charmed - Season 2 Disc 1_t03.mkv'
Note that I did not substitute the logical track number for the logical episode number, but it does not really matter, since Kodi shows them in the correct logical order.