Zodler
December 27, 2018, 8:17pm
1
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
[{000214A0-0000-0000-C000-000000000046}]
Prop3=19,11
[InternetShortcut]
IDList=
URL=https://www.imdb.com/title/tt7905466/
I want to extract tt7905466 and rename the file to imdb.tt7905466.url
Leo
December 27, 2018, 9:20pm
2
This might be a good starting point. It adds the first line of each file to the names:
1 Like
Zodler
December 28, 2018, 12:47am
3
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.search("imdb.com/title/tt ");
}
line = line.substr(found + 15,9);
}
2 Likes
lxp
December 28, 2018, 9:55am
4
Alternatively you could regex the id from the metadata:
function OnGetNewName(getNewNameData) {
if (getNewNameData.item.Metadata.other.target_type != 'url') return;
var temp = String(getNewNameData.item.Metadata.other.target);
var tempExt = getNewNameData.newname_ext;
temp = temp.replace(/.*\/title\/(.*?)(\/|$)/g, '$1');
return 'imdb.' + temp + tempExt;
}
1 Like