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

How to open a dialog to pick a file or enter a filename?

Community Beginner ,
Dec 28, 2016 Dec 28, 2016

Copy link to clipboard

Copied

Hi community,

I’m writing a script in JavaScript to process some images and save the result and some metadata in a folder and file chosen by the user.

Is there an API do that? i.e. to open a dialog similar to Photoshop’s save as dialog, so that the user can either pick a file already in the disk or enter the filename to create a new one.

I don’t want the dialog to save anything but just to return the full path to the file.

Best regards.

TOPICS
Actions and scripting

Views

3.0K

Translate

Translate

Report

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 , Dec 29, 2016 Dec 29, 2016

rraallvv77 schrieb:

… I don’t want the dialog to save anything but just to return the full path to the file.

Best regards.

I don't know what do you really want.

var aDoc = activeDocument;

var fName = aDoc.name;

alert(fName);

try {

    var fPath = aDoc.path;

    alert(fPath);

    }

catch (e) { alert(fName + " was never saved before") }

e.g. gives you the file name and the path (if your document has a file path - was saved)

File.saveDlg();

Gives you a dialog for saving.

What do you really want to do?

Votes

Translate

Translate
Adobe
Enthusiast ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

From documentation:

Application.openDialog (): FileArray

Adobe Photoshop CC 2015.5 Object Library

Uses the Photoshop open dialog to select files.

Example:

alert(app.openDialog ());

Votes

Translate

Translate

Report

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 ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

rraallvv77 schrieb:

… I don’t want the dialog to save anything but just to return the full path to the file.

Best regards.

I don't know what do you really want.

var aDoc = activeDocument;

var fName = aDoc.name;

alert(fName);

try {

    var fPath = aDoc.path;

    alert(fPath);

    }

catch (e) { alert(fName + " was never saved before") }

e.g. gives you the file name and the path (if your document has a file path - was saved)

File.saveDlg();

Gives you a dialog for saving.

What do you really want to do?

Votes

Translate

Translate

Report

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 Beginner ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

pixxxel schubser , I think saveDlg is the one I wanted thanks.

Jarda Bereza​, I already tried openDialog and searched in the photoshop-cc-javascript-ref-2015.pdf document but couldn't find anything similar to saveDlg, maybe the documentation is incomplete or I downloaded the wrong file, thanks.

Votes

Translate

Translate

Report

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 ,
Dec 29, 2016 Dec 29, 2016

Copy link to clipboard

Copied

LATEST

You're welcome.

Furthermore File.saveDialog() method also exists.

Votes

Translate

Translate

Report

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