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

Open multiple Files as per Trim Size

Enthusiast ,
May 28, 2015 May 28, 2015

Copy link to clipboard

Copied

Hi All,

Please help for my request, this should be very urgent.

Request:

1. User Select Folder

2. Open all Files

3. Collect Trim Size (document width) + Document Name

4. Sort the Document Width (lower value to higher value)

5. Again open the Files as per minimum document width

Trying Script:

#target Indesign

var  myFolder = Folder.selectDialog("Select the Folder contains Indesign Files");

var myFiles = myFolder.getFiles("*.indd");

myWidthArray = new Array();

for(i=0; i<myFiles.length; i++)

{

    app.open(myFiles);

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT; 

   

    var myDocument_Width = Math.round(app.activeDocument.documentPreferences.pageWidth);

    var myReq = myDocument_Width + app.activeDocument.name;

   

    myWidthArray.push(myReq)

   

    app.activeDocument.close();

    }

alert(myWidthArray)

var myPoints = myWidthArray;

myPoints.sort(function(a, b){return a-b});

alert("myPoints: " + myPoints)

//here need help

for(k=0; k<myPoints.length; k++)

{

    app.open(myPoints.document.name)

    }

Thanks

Siraj

TOPICS
Scripting

Views

513
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

correct answers 1 Correct answer

Contributor , May 29, 2015 May 29, 2015

Hi try this code

#target Indesign

var  myFolder = Folder.selectDialog("Select the Folder contains Indesign Files");

var myFiles = myFolder.getFiles("*.indd");

var myWidthArray = new Array();

for(var i=0; i<myFiles.length; i++)

{

    app.open(myFiles);

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;  

    

    var myDocument_Width = Math.round(app.activeDocument.documentPreferences.pageWidth);

    // store the values as object

    var myReq = {w:m

...

Votes

Translate
Enthusiast ,
May 29, 2015 May 29, 2015

Copy link to clipboard

Copied

Hi Siraj,

Is this you need?

#target Indesign 

 

var  myFolder = Folder.selectDialog("Select the Folder contains Indesign Files"); 

var myFiles = myFolder.getFiles("*.indd"); 

myWidthArray = new Array(); 

 

for(i=0; i<myFiles.length; i++) 

    app.open(myFiles); 

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;   

     

    var myDocument_Width = Math.round(app.activeDocument.documentPreferences.pageWidth); 

    var myReq = myDocument_Width + app.activeDocument.name; 

    myWidthArray = [];

    myWidthArray.push(myDocument_Width)

    myWidthArray.push(app.activeDocument.name)

    app.activeDocument.close(); 

    } 

myWidthArray.sort(); 

 

//here need help 

for(k=0; k<myWidthArray.length; k++) 

    app.open(File(myFolder + "/"+ myWidthArray[1]));

    }

Regards,

Chinna

Votes

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
Enthusiast ,
May 29, 2015 May 29, 2015

Copy link to clipboard

Copied

Hi Chinna,

Thank you for your immediate response...

Could you please see the alert, this should not sort correctly.

For testing purpose, I created 4 files and test it.

I alert in the provided script:

var myOutput = myWidthArray.sort();

alert(myOutput)

Please look into this.

Screen Shot 2015-05-29 at 12.56.41 PM.png

But my need is

40,small_tsserd.indd, 210,bbb.indd, 400,abcd.indd, 1200,large_yyyde.indd

Again thanks for your support.

Votes

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 ,
May 29, 2015 May 29, 2015

Copy link to clipboard

Copied

Hi try this code

#target Indesign

var  myFolder = Folder.selectDialog("Select the Folder contains Indesign Files");

var myFiles = myFolder.getFiles("*.indd");

var myWidthArray = new Array();

for(var i=0; i<myFiles.length; i++)

{

    app.open(myFiles);

    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;  

    

    var myDocument_Width = Math.round(app.activeDocument.documentPreferences.pageWidth);

    // store the values as object

    var myReq = {w:myDocument_Width, d:app.activeDocument.name};

  

    myWidthArray.push(myReq);

    app.activeDocument.close(); 

    }

alert(myWidthArray.toSource());

var myPoints = myWidthArray;

// sort by width

myPoints.sort(function(a, b){return a.w * 1-b.w * 1});

alert("myPoints: " + myPoints.toSource());

//here need help

for(var k=0; k<myPoints.length; k++)

{

    // reopen documents in selected folder

    // open with fullpath

    app.open(new File(myFolder + '/' + myPoints.d));

    }

  

thank you

Votes

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
Enthusiast ,
May 29, 2015 May 29, 2015

Copy link to clipboard

Copied

LATEST

Hi Chinna/Milligramme,

Excellent support in your busy schedule.

Milli: Your coding is working fine in my end.

Again Thanks a lot guys!!!!

Votes

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