sorry, I don't know what to do with that code 😞
This is what I want look like

OK. So you want the document name first. Try this:
var doc = app.activeDocument;
var name1 = app.activeDocument.name;
for (var i = 0; i < doc.artboards.length; i++) {
doc.artboards.setActiveArtboardIndex(i);
doc.selectObjectsOnActiveArtboard();
for (var j = 0; j < selection.length; j++) {
if (selection[j].typename == "PlacedItem") {
var name2 = decodeURI(selection[j].file.name).replace(/\.[^\.]+$/, "");
doc.artboards[i].name = name2;
var d = doc.artboards[i].artboardRect;
var rect1 = doc.pathItems.rectangle(d[1] - 10, d[0] + 10, (d[2] - d[0]) - 20, 40);
var text1 = doc.textFrames.areaText(rect1);
text1.contents = name1 + " - " + name2;
break;
}
}
}
If you want them on two separate lines, change the line before last to
text1.contents = name1 + "\r" + name2;