Code: Select all
$srtFiles = listfolder("<curpath>", "*.srt", 5, "<crlf>");
$movieFiles = listfolder("<curpath>", "*.mp4", 5, "<crlf>");
foreach($file, $movieFiles, "<crlf>") {
$baseName = getpathcomponent($file, "base");
$ndleading = regexreplace($file, "(^\d+_)(\d+)(-.*)", "$2");
$match = regexmatches($srtFiles, "$ndleading.*?(?=$)");
if (gettoken($match, "count", "|") == 1) {
renameitem($baseName, $match);
}
}
Go into the folder that contains the .mp4 and .srt files and execute the above script.
It renames only those files for which it finds a unique match (based on the second leading number of the .mp4 file name).
Ofc you should test it with a copy of your files (a few would be enough) first!