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

using filter expression in file.openDialog

Participant ,
Oct 16, 2014 Oct 16, 2014

Reading the Adobe JavaScript pdf. I am unable to fully comprehend how one might filter the range of available files in the File.openDialog. I'd like to have the choices limited to .csv files. I know I need to have a different method depending on whether the user is on a mac or PC.

TOPICS
Scripting
1.8K
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

correct answers 1 Correct answer

Enthusiast , Oct 17, 2014 Oct 17, 2014

Understanding the filter function on OSX was non obvious for me as well.  There is version of the Adobe's JavasScript Tools Guide that has an actual example of the filter function, then I found this thread which has a pretty good example implementation.  Then there's the StackOverflow answer to a question I posted about this issue.  Hope those references help.

Translate
Advocate ,
Oct 16, 2014 Oct 16, 2014

I used it once in a scipt, like this:

file = File.openDialog("Select the target file.",

                                    File.fs.toUpperCase() === "WINDOWS" ? "Text Files:*.txt,Javascript Files (CARE OVERWRITE):*.jsx,All Files (CARE OVERWRITE):*.*" : function(f){return f.name.slice(-4)===".jsx" || f.name.slice(-4)===".txt";},

                                    false);

I worked on Windows, i don't have a clue if it would work on Mac, never tested it.

Xavier

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 ,
Oct 17, 2014 Oct 17, 2014

Understanding the filter function on OSX was non obvious for me as well.  There is version of the Adobe's JavasScript Tools Guide that has an actual example of the filter function, then I found this thread which has a pretty good example implementation.  Then there's the StackOverflow answer to a question I posted about this issue.  Hope those references help.

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
Participant ,
Oct 17, 2014 Oct 17, 2014
LATEST

Perfect answers. Working now. Thanks.

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