Log in

View Full Version : Batch AVI- Mkv- Script


gollum007
11th January 2008, 21:00
Hiya,
A while back, someone posted a script to batch convert AVI to MKV I've spent several hours improving this & thought it only fair that I post the improved version-
while(<*>)
{
$o = $_;
s/\ /\¬/g;
rename($o, $_);
}
while(<*>)
{
$o = $_;
s/\.AVI/\.avi/g;
rename($o, $_);
}
while(<*>)
{
$o = $_;
s/\.OGM/\.ogm/g;
rename($o, $_);
}
foreach (<*.avi>) {
$cmd = "mkvmerge $_ -o ";
s/\.avi$/.mkv/;
$cmd .= $_;
system($cmd);
}
@filelist = glob("*.avi");
unlink @filelist;
foreach (<*.ogm>) {
$cmd = "mkvmerge $_ -o ";
s/\.ogm$/.mkv/;
$cmd .= $_;
system($cmd);
}
@filelist = glob("*.ogm");
unlink @filelist;
while(<*>)
{
$o = $_;
s/\¬/\ /g;
rename($o, $_);
}

In a nutshell, this script first removes all spaces from the filenames, then converts any AVIs to MKV, deletes the original AVI files, and finally puts the spaces back again :)

Save to conversionscript.pl (Or whatever else ;) ) and double-click from Windows explorer.
Needs MKVToolnix & Active Perl installed.

Cheers

-Gollum

gollum007
14th January 2008, 14:43
Sorry, slightly improved version :)
Have tweaked the script not to remove any existing underscores and added processing for OGMs in the same way. (This requires a recent devel version of MKVToolnix; OGM muxing is broken in the current release)

Edit: Sorry, third fix- Capitilisation of extensions was causing some issues with MKVMerge, added a couple of lines to sort this :)


Most probably not the most efficient of scripts I know, but it does what its designed to do perfectly.

Cheers

-Gollum