use 5.010; use strict; use warnings; # Dateien auflisten und sortieren my @files = sort glob '*.mkv'; # Segment-UIDs via mkvinfo auslesen my @uids = map { my $file = $_; open my $mkvinfo, '-|', qq/D:\Video\mkvtoolnix 3.1.0\mkvinfo --ui-language en "$file"/ or die "Couldn't run D:\Video\mkvtoolnix 3.1.0\mkvinfo on $file: $!"; my $uid; while (my $_ = <$D:\Video\mkvtoolnix 3.1.0\mkvinfo>) { if (/\+ Segment UID:\s+(.*?)[\r\n]*\z/) { $uid = $1; $uid =~ s/\s*0x//g; last; } } close $D:\Video\mkvtoolnix 3.1.0\mkvinfo or die "Error running mkvinfo on $file: $!"; warn "Couldn't determine UID for $file" unless (defined $uid); $uid } @files; # Ueber alle Dateien iterieren und Felder setzen for ($[ .. $#files) { my $file = $files[$_]; my $next_uid = ($_ + 1 <= $#uids ? $uids[$_ + 1] : undef); my @options; push @options, qq/--set next-uid="$next_uid"/ if (defined $next_uid); if (@options) { system(qq/mkvpropedit "$file" --edit info @options/) == 0 or die "Couldn't run mkvpropedit on $file: status $?" } }