Rename .srt file based on .mkv in same folder

@Leo how could we do rename automation withing the same folder using the filename of a video file (mkv) to rename a subtitles file (srt) plus adding an language designator (.ENG)? To illustrate:

Files within the same folder
abc.mkv
123.srt

By selecting 123.srt and a button click we want to be renamed to abc.ENG.srt.

Similarly in flat-view, selecting multiple .srt files, these to be renamed based on the video-filename (usually mkv) contained in the same folder (condition: the folder contains only one video file).

Thank you for a great piece of software and always awesome support!

1 Like

Rename preset:

For reference, the rename script (JScript):

function OnGetNewName(getNewNameData)
{
	var mkvName = "";
	var dir = DOpus.FSUtil.ReadDir(getNewNameData.item.path);
	while(!dir.complete)
	{
		var item = dir.Next();
		if (item.ext.toUpperCase() == ".MKV")
		{
			if (mkvName == "")
				mkvName = item.name_stem;
			else
				return; // Too many MKV files.
		}
	}

	if (mkvName == "")
		return; // No MKV file.

	return mkvName + ".ENG" + getNewNameData.newname_ext;
}
1 Like

@Leo the JS code works fine within the rename presets. I have tried to place it in a button (following How to use buttons and scripts from this forum - #2 by Leo) by selecting Script Type "JScript" and pasting the code there but no luck. Any special instructions please?

See Using a Rename Preset outside the Rename Dialog

1 Like

@Leo Great! Thank you!

Hi @Leo ,

I tried using this to change subtitle names, but it's not working.

I want to easily copy the name from the MKV file to the SRT file with just one click of a button.

How can I do this?

Thanks!

@Mitev I have upgraded to DOpus 13 from DOpus 12 (Well done @Leo!) and this works fine, via the RENAME feature, for both MKV and MP4 files:

SRT from MKV.orp (736 Bytes)
SRT from MP4.orp (736 Bytes)

Make sure to have only ONE MKV/MP4 file within the folder you are performing the rename.

1 Like