Copy link to clipboard
Copied
hi there,
any idea how to get the txt filename being placed by ctrl+D using JS?
Thanks!
Copy link to clipboard
Copied
Try this
Multi file auto place
//**********************
var myDoc = app.activeDocument,
myFiles = File.openDialog("Select files to place...", undefined, true),
i,
currentPage = myDoc.pages[0],
prevFrame,
myFrame;
for (i = 0; i < myFiles.length; i++){
myFrame = addFrame(currentPage);
myFile = myFiles;
try{
myFrame.place(myFile, false);
}
catch(e){
alert("Unable to place file: "+myFile, "Multi-file auto-place");
continue;
}
while (myFrame.overflows){
currentPage = addPageAfter(currentPage);
prevFrame = myFrame;
myFrame = addFrame(currentPage);
prevFrame.nextTextFrame = myFrame;
}
currentPage = addPageAfter(currentPage);
}
function addFrame(aPage){
var pageMargins = aPage.marginPreferences,
aFrame = aPage.textFrames.add(),
areFacing = app.activeDocument.documentPreferences.facingPages,
myTop = aPage.bounds[0]+pageMargins.top,
myBottom = aPage.bounds[2]-pageMargins.bottom,
myLeft = aPage.bounds[1]+pageMargins.left,
myRight = aPage.bounds[3]-pageMargins.right;
//When document.documentPreferences.facingPages == true,
//"left" means inside; "right" means outside.
if (areFacing && aPage.side == PageSideOptions.LEFT_HAND){
myLeft = aPage.bounds[1]+pageMargins.right;
myRight = aPage.bounds[3]-pageMargins.left;
}
aFrame.geometricBounds = [myTop, myLeft, myBottom, myRight];
return aFrame;
}
function addPageAfter(aPage){
return myDoc.pages.add(LocationOptions.AFTER, aPage);
}
//***************
Thanks
Copy link to clipboard
Copied
Thanks for your reply.
I think you have mistaken my question.
i needed a JS that's able to obtain the actual fileNAME of the .txt that was placed using the default "PLACE" action.
e.g "123.txt"
Copy link to clipboard
Copied
Hi Ebo,
As text file is placed as textFrame not as linked items. So its actual name can't accessible.
...Thanks
Ravindra
Copy link to clipboard
Copied
Hi
Make sure you check the preference in as shown below, before you place the text file
It will store text file as link. Hence you can get the file name from link palette.