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
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
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
}
Regards,
Chinna
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.
But my need is
40,small_tsserd.indd, 210,bbb.indd, 400,abcd.indd, 1200,large_yyyde.indd
Again thanks for your support.
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
Copy link to clipboard
Copied
Hi Chinna/Milligramme,
Excellent support in your busy schedule.
Milli: Your coding is working fine in my end.
Again Thanks a lot guys!!!!