Rename based on text inside the file

I'm trying for a rename preset to extract a text from inside the file and add it to the filename.

I have imdb.url files that include a link to iMDB. Inside the files are text like this


I want to extract tt7905466 and rename the file to imdb.tt7905466.url

This might be a good starting point. It adds the first line of each file to the names:

1 Like

Thank you. It was not easy but after several hours I added this

var found = -1;
if (tf != null) {
if (!tf.AtEndOfStream) {
while (found == -1) {
line = tf.ReadLine();
found ="");
line = line.substr(found + 15,9);


Alternatively you could regex the id from the metadata:

function OnGetNewName(getNewNameData) {

    if (getNewNameData.item.Metadata.other.target_type != 'url') return;

    var temp = String(;
    var tempExt = getNewNameData.newname_ext;

    temp = temp.replace(/.*\/title\/(.*?)(\/|$)/g, '$1');

    return 'imdb.' + temp + tempExt;

1 Like