• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

JS to get the txt filename after being placed.

Participant ,
Jun 13, 2016 Jun 13, 2016

Copy link to clipboard

Copied

hi there,

any idea how to get the txt filename being placed by ctrl+D using JS?

Thanks!

TOPICS
Scripting

Views

294

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jun 13, 2016 Jun 13, 2016

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 13, 2016 Jun 13, 2016

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"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 13, 2016 Jun 13, 2016

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 14, 2016 Jun 14, 2016

Copy link to clipboard

Copied

LATEST

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.

Screen Shot 2016-06-14 at 2.17.24 pm.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines