Copy link to clipboard
Copied
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
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
Copy link to clipboard
Copied
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();
Copy link to clipboard
Copied
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");
Copy link to clipboard
Copied
Thank you for your help
Just what i was looking for.
/T
Find more inspiration, events, and resources on the new Adobe Community
Explore Now