Apply Linked Name to Document Script
Hello. We recently made some changes to our file naming scheme and I am in need of some assitance updating our linked name script to apply the correct file name to our document.
Here is the old script
function test()
{
var myItem = app.activeDocument.selection[0]; // be sure that a linked item (and not an embedded) is selected
var myItemBounds = myItem.visibleBounds;
var myItemHeight = Math.abs(myItemBounds[3] - myItemBounds[1]);
var aTF = app.activeDocument.textFrames.add();
var fileName = myItem.file.name;
var textContents = fileName.replace(/\%20/g, " "); //change %20 to spaces
var frontMatter = textContents.slice(0,textContents.indexOf("_"));
var backMatter = textContents.slice((textContents.lastIndexOf("_") + 1), textContents.lastIndexOf("."));
textContents = frontMatter + "_" + backMatter;
aTF.position = [myItemBounds[0], myItemBounds[1] - myItemHeight];
aTF.contents = textContents; //add the textContents to the textFrame.
}
test();
Old File Name: 115340-2-1_Just the head(s)_3x3_X1
Old Output: 115340-2-1_X1
New File Name: Sticker_IF_115340-2-1_Just the head(s)_3x3_X1
Output with script: Sticker_X1
I am wanting like orginal output: 115340-2-1_X1
Need it to ignore the Sticker_IF_ and apply just the OrderNum & QTY
Any help would be greatly appreciated.
