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

File Open dialog with filter

Community Beginner ,
Jul 31, 2009 Jul 31, 2009

Hi,

   When I am invoking the following command in Adobe Indesign JavaScript in Windows OS, the filter option does not work.

var myFile=File.openDialog("Choose the file","*.jsx",false);

I need to limit the types of files displayed in the dialog. "*.jsx" filter expression does not work in the dialog. It displays all types of files in the dialog.

Please suggest the solution to the above problem.

TOPICS
Scripting
8.3K
Translate
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
LEGEND ,
Jul 31, 2009 Jul 31, 2009

Try this:

function filterFiles(file){
	if(file.name.match(/\.jsx$/)){return true}
	return false
}
file = File.openDialog ("Choose the file" , filterFiles, false );

Harbs

Translate
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 ,
Feb 27, 2014 Feb 27, 2014

how modify this code to include folders (make them activate)?

because on Mac in folder's "column view" folders are grayed out and it is impossible to dig into them to reach files hidden deeper in the folders hierarchy.

Translate
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 ,
Feb 28, 2014 Feb 28, 2014
LATEST

Hi kumar1981

I use the following function.

You have to replace the ".xml" with your extension 😉

kind regards

Daniel (from Switzerland)

function maskFile(myFile) {

  if (myFile.constructor.name == "Folder") { return true }

  if (myFile.name.slice(-4) == ".xml") { return true }

  return false;

}

Translate
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