Copy link to clipboard
Copied
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.
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");
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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");
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
you're welcome
Copy link to clipboard
Copied
Can you create a call back function on openDlg?
Copy link to clipboard
Copied
what do you mean?
Copy link to clipboard
Copied
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)
}
})
Copy link to clipboard
Copied
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
}
})
Copy link to clipboard
Copied
that works, except "doc" is not defined.
so you're ok now? do you need anything else?
Copy link to clipboard
Copied
I'm good. Thanks.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more