Skip to main content
Inspiring
December 5, 2011
Answered

Probably an easy answer...

  • December 5, 2011
  • 2 replies
  • 871 views

Ok, this is probably an easy answer, but having some trouble figuring it out, there's no documentation in the scripting manual. I'm looking to open a file with the open dialog like so:

var myFile = File.openDialog("Choose a File");

How do you filter file types for Mac? (looking to open an InDesign document)

This topic has been closed for replies.
Correct answer absqua

var file = File.openDialog("Choose a File", function(file){

     if(file instanceof Folder || file.displayName.split(".").pop() === "indd"){

          return true;

     }

     return false;

});

2 replies

Inspiring
December 6, 2011

Alright, that makes some sense, the script Absqua posted there works well.

Peter Kahrel
Community Expert
Community Expert
December 5, 2011

Try this:

var myFile = File.openDialog ("Choose a file", "Documents:*.indd", true);

Peter

Inspiring
December 5, 2011

Hmm, that still doesn't seem to be working... here's from the manual:

filteranyA filter that limits the types of files displayed in the dialog. (default: null)

• In Windows, a filter expression such as "Javascript files:*.jsx;All files:*.*".
• In Mac OS, a filter function that takes a File instance and returns true if the file should be included in the display, false if it should not. (Optional)
absquaCorrect answer
Inspiring
December 5, 2011

var file = File.openDialog("Choose a File", function(file){

     if(file instanceof Folder || file.displayName.split(".").pop() === "indd"){

          return true;

     }

     return false;

});