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 }
![Exclamation :!:](./images/smilies/icon_exclaim.gif)
![Screenshot](https://i.snipboard.io/YfaKeH.jpg)
![Screenshot](https://i.snipboard.io/ioAzvN.jpg)
Option B: Use the {mediaFile} binding to find the primary media file
![Idea :idea:](./images/smilies/icon_idea.gif)
Format: Select all
{ mediaFile.dir }/{ mediaFile.nameWithoutExtension }{ subt }
![Exclamation :!:](./images/smilies/icon_exclaim.gif)
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
}
![Screenshot](https://i.imgur.com/1JqMzXw.png)
![Screenshot](https://i.imgur.com/qKWXx11.png)
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]