Option A: Use the {folder} binding to find nearby files
Use Case: Use a Plain File Mode custom Preset to rename the given files so that the each file is assigned the same file name as the largest file in the same folder.Format: Select all
{ folder.files.max{ it.length() }.nameWithoutExtension }{ subt }



Option B: Use the {mediaFile} binding to find the primary media file

Format: Select all
{ mediaFile.dir }/{ mediaFile.nameWithoutExtension }{ subt }

Option C: Use the name of the n-th video file in the folder to rename the n-th subtitle file in the folder
Use Case: If files are in order, then the n-th video file typically matches the n-th subtitle file, and if that assumption indeed holds true for your files, then matching video / subtitle files is trivial:Format: Select all
{
def index = folder.listFiles{ it.hasExtension(ext) }.indexOf(f)
def videoFile = folder.listFiles{ it.video }.get(index)
videoFile.nameWithoutExtension
}


Console Output: Select all
$ filebot -rename *.srt --db file --format "{ def index = folder.listFiles{ it.hasExtension(ext) }.indexOf(f); def videoFile = folder.listFiles{ it.video }.get(index); videoFile.nameWithoutExtension }"
Rename files using [Plain File]
[MOVE] from [1.srt] to [Alias.1x01.srt]
[MOVE] from [2.srt] to [Avatar.2009.srt]