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

How to make a dialog box for a user to choose a file from disk

New Here ,
Oct 21, 2009 Oct 21, 2009

Hi there

Is it possible to make a dialog box, for a photoshop user, to choose a txt file, to be process by my javascript ?

I have a txt file with all the names and locations of psd files i want to process by photoshop. I have ex. 100 out of a folder with 250 images.

If anyone have a shot "code sample" how to select a file - i will be happy.

/T

TOPICS
Actions and scripting
5.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

Valorous Hero , Oct 21, 2009 Oct 21, 2009

Here is an example of selecting a text file...

var dlg=
"dialog{text:'Script Interface',bounds:[100,100,500,220],"+
"testFile:EditText{bounds:[10,40,310,60] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse:Button{bounds:[320,40,390,61] , text:'<<' },"+
"statictext0:StaticText{bounds:[10,10,240,27] , text:'Please select Text File' ,properties:{scrolling:undefined,multiline:undefined}},"+
"Process:Button{bounds:[10,80,190,101] , text:'Process' },"+
"button2:Button{bounds:[2

...
Translate
Adobe
Valorous Hero ,
Oct 21, 2009 Oct 21, 2009

Here is an example of selecting a text file...

var dlg=
"dialog{text:'Script Interface',bounds:[100,100,500,220],"+
"testFile:EditText{bounds:[10,40,310,60] , text:'' ,properties:{multiline:false,noecho:false,readonly:false}},"+
"Browse:Button{bounds:[320,40,390,61] , text:'<<' },"+
"statictext0:StaticText{bounds:[10,10,240,27] , text:'Please select Text File' ,properties:{scrolling:undefined,multiline:undefined}},"+
"Process:Button{bounds:[10,80,190,101] , text:'Process' },"+
"button2:Button{bounds:[210,80,390,101] , text:'Cancel' }};"
var win = new Window(dlg,'test');
win.center();
win.testFile.enabled=false;
win.Browse.onClick = function() {
selectedFile = File.openDialog("Please select TEXT file.","TEXT File:*.txt");
  if(selectedFile != null) win.testFile.text =  decodeURI(selectedFile.fsName);
}
win.Process.onClick = function() {
if(win.testFile.text == '') {
  alert("No text file has been selected!");
  return;
  }
win.close(1);
selectedFile.execute();
}
win.show();

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
Guru ,
Oct 21, 2009 Oct 21, 2009

Also unless you have some other need for the dialog you can skip it and just use

var selectedFile = File.openDialog("Please select TEXT file.","TEXT File:*.txt");

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
New Here ,
Oct 23, 2009 Oct 23, 2009
LATEST

Thank you for your help

Just what i was looking for.

/T

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