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

Create a file selection dialog

Explorer ,
Apr 24, 2014 Apr 24, 2014

I've recently finished a script that does all sorts of things based on a folder selected by the user. One of the first things it does is open a specific file, which isn't a problem at all, I just told it which file to open and it did.

The thing is, I'd like to allow the user to select which file to use, as we have more than a couple options, depending on what the end result will be. Is it possible to replace the open(fileRef); in that script with a list of the files in a certain folder that the user gets to select one of? From there, that selection would act as fileRef throughout the rest of the script.

Off topic, in that thread I linked, I answered some of my own questions. While I know you aren't supposed to create fake usernames to award helpful and correct answers, is it bad ettiquette to asign them to myself? I thought if someone were to need something similar, the answers I marked helpful would be, just that, helpful.

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

Community Expert , Apr 24, 2014 Apr 24, 2014

sure you can hard code the starting folder name, or get one of the standard folders, then use the openDlg() function

var mydesktop = Folder.desktop;

mydesktop.openDlg ("Select file, preselecting this folder");

Translate
Adobe
Community Expert ,
Apr 24, 2014 Apr 24, 2014

check this thread, I have a script that asks for a file, adapt it to your needs.

http://forums.adobe.com/message/5538469#5538469

it is ok to mark your own answers as correct, bad etiquette would be someone giving you the answer and marking your own, not saying "thanks", coming back for your answer and disappear without saying anything,

...saying "thanks" but not marking as correct or helpful is not bad etiquette but it helps keeping the forum organized...nobody cares about the points awarded, it just helps tremendously in keeping track of what's pending and what's not.

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 ,
Apr 24, 2014 Apr 24, 2014

Awesome, thank you. I thought that would most likely be the case. I feel bad enough about how long my original question was in that last thread and wanted to point out the helpful answers along the way.

And thanks for the link, I'm going to go check it out now!

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 ,
Apr 24, 2014 Apr 24, 2014

I was able to use that script you mentioned to figure out the file openDialog. However, I'm wondering if there's a way to specify the starting location of the dialog. Rather than have it go to the last used location, have it go to a new, different location.

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
Community Expert ,
Apr 24, 2014 Apr 24, 2014

sure you can hard code the starting folder name, or get one of the standard folders, then use the openDlg() function

var mydesktop = Folder.desktop;

mydesktop.openDlg ("Select file, preselecting this folder");

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 ,
Apr 24, 2014 Apr 24, 2014

ah, that's how. I had been trying to do it like how you are given the option to specify a folder in the Folder.selectDialog, but obviously, that option is part of the file.openDlg so it wasn't working.

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
Community Expert ,
Apr 24, 2014 Apr 24, 2014

you're welcome

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
Engaged ,
Apr 11, 2019 Apr 11, 2019

Can you create a call back function on openDlg?

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
Community Expert ,
Apr 11, 2019 Apr 11, 2019

what do you mean?

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
Engaged ,
Apr 11, 2019 Apr 11, 2019

I want to paste the selected file. So after the dialog closes I want to use the file object to place it on the page. But the script has to wait until the dialog is finished. The parameters for open dialog are prompt,filter, and mulitSelect. So I can't add it there.

function placeFile(callback){

   var mydesktop = Folder.desktop; 

   var fileToPlace=mydesktop.openDlg ("Select file, preselecting this folder");

   var data=[fileToPlace,finished=true]

   

    }

   placeFile(function(data){

           if(data[1]==true){

         //var selectedImage = new File (data[0]);

     placeFiles.file = data[0];

        $.writeln(data)

          }

   

      })

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
Engaged ,
Apr 11, 2019 Apr 11, 2019

function placeFile(callback){

  var mydesktop = Folder.desktop;

  var fileToPlace=mydesktop.openDlg ("Select file, preselecting this folder");

  var data=[fileToPlace,finished=true]

    callback(data)

    }

if (app.documents.length != 0){

    var finished=false;

    var zeroPoint=app.activeDocument.rulerOrigin = [90,744.5]/////Set the zero pointof top left corner for starting.

    //ui ();

    placeFile(function(data){

        if(data[1]==true){

            var itemToPlace = doc.placedItems.add();

            var selectedImage = new File (data[0]);

            itemToPlace.file=selectedImage

            }

    

        })

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
Community Expert ,
Apr 12, 2019 Apr 12, 2019

that works, except "doc" is not defined.

so you're ok now? do you need anything else?

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
Engaged ,
Apr 15, 2019 Apr 15, 2019
LATEST

I'm good. 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