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

OpenDialog to a specific folder

People's Champ ,
Jun 02, 2008 Jun 02, 2008
Hi,
I saw this question was discussed already but following the tip, I don't have any success. Moreover I couldn't post in the thread so I have to open this topic. Sorry about that.

Well,
here is the matter :
var myfile = File("\\192.168.1.1\Marketing\17. Produits\COPY\Tiff_CMYK_300dpi\ok\copyripok_uk.tif");
myfile.openDialog(); // > ERROR

/*

File.openDialog() // Works great.

*/

So it's so annoying. Where am I wrong ?
Thanks for help
Loic
TOPICS
Scripting
4.3K
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
Guest
Jun 02, 2008 Jun 02, 2008
myFile.openDlg();

Bob
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
People's Champ ,
Jun 02, 2008 Jun 02, 2008
Hi Bob
Thanks for taking the time to answer.
Unfortunately, I am still stuck. I get a null info when trying this.
It's like Indesign tried to open the dialog (the app seems to vibrate) but nothing appears at the end and the javascript console says null.
Loic
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
People's Champ ,
Jun 02, 2008 Jun 02, 2008
Hi,
some news,
I get a result if the file is placed on my hard drive ("c:/...") but it still fails when the file is on a server ("\\192.168.1.1\...").
Is there any way to solve this ?
Loic
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
Guest
Jun 02, 2008 Jun 02, 2008
Exactly.

The File object doesn't play all that well with servers unless the drive is mounted. That hasn't been a requirement for me, so I don't know if you can do that without mounting the server drive or not.

myFile.exists will tell you if you've managed to point to the server correctly.

Bob
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
People's Champ ,
Jun 02, 2008 Jun 02, 2008
Ok thanks for all your advices.
I guess I will have to try replacing the complete data (\\192.168...) by a shorter version (i.e. for example g:/...).
I ll keep you in touch.
Loic
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
Guest
Aug 05, 2008 Aug 05, 2008
Hi Loic/Bob,

Using openDlg, is there a parameter to select multiple files?

Regards
Norbert
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
People's Champ ,
Aug 06, 2008 Aug 06, 2008
File.openDialog (prompt, filter, multiSelect)
so
File.openDialog ("Pick me...", undefined, true) //Undefined when the parameter is not required.
Hope it helps
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
Participant ,
Aug 06, 2008 Aug 06, 2008
If you want to Filter files, and you want your script to work on either platform, then you need to use platform-specific code, along these lines:
(function() {


var myFile = getDocFile();
if (myFile == null) return;
alert(myFile.creator + " " + myFile.type);

function getDocFile() {
// cross-platform document file selector
if (File.fs == "Windows") {
var select = "InDesign documents:*.INDD"
} else {
var select = filterFiles
}
myFile = File.openDialog("Choose an InDesign document:", select);
return myFile;
function filterFiles(file) {
while (file.alias) {
file = file.resolve();
if (file == null) { return false }
}
if (file.constructor.name == "Folder") return true
var extn = file.name.toLowerCase().slice(file.name.lastIndexOf("."));
switch (extn) {
case ".indd" : return true;
default : return false
}
}
}
}())
If you've not seen an anonymous function before, don't be put off. Wrapping a script in an anonymous function protects the global name space.

Notice the filtering mechanism. Windows users have it easy. Just get that string right and Windows does the whole job for you (although if you look across a network to a Mac disk that has aliases on it, Windows won't be able to service those for you).

Mac users have to deal with aliases (that's what the while loop is about -- resolving until it either finds a file or a broken alias). Then keeping folders active.

This particular code doesn't work if you have files on your Mac disks that lack extensions, but that's so 20th Century.

The most common mistake Windows users make (or, to be more honest, I make when I'm doing the Windows string) is to forget the prefix. If you hand Windows a string like: "*.EPS, *.TIF" you'll get the wrong File dialog and the one you get is much harder to work with. You need something like: "Graphics files: *.EPS, *TIF".

In this example, I've used the filter with openDialog, but the same approach can be used with openDlg (which takes the same three arguments -- albeit, I've only used the first two in this example).

Dave
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
Participant ,
Aug 06, 2008 Aug 06, 2008
One odd thing about the Mac side is that no matter what you do, application files are always active, but they're treated as files, not folders, so you can't see into a product package. It's hard to tell if this is deliberate or accidental behavior. It just is.

I'm not sure what happens if you use openDlg with a File that is inside a package -- that might work. I haven't tried it.

Dave
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
Guest
Aug 06, 2008 Aug 06, 2008
Hi Loic and Dave,

Thanks for your responses. Filtering files is not an issue.

Loic. I tried adding a third parameter heres the code

myDocs = File(myFolder+"/"+myMask)
myFile=myDocs.openDlg("Select Files To Open", myFolder+"/"+myMask.indd, true);
app.open(myFile)

This doesn't work

Regards
Norbert
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
People's Champ ,
Aug 07, 2008 Aug 07, 2008
Hi,
I would say that's because your filter parameter is not as expected.
It should be something like "Files : *.indd".
The filter will only exclude file types that are not the one expected.
So if you want to open a specific file on your hard drive you have to say
app.open(File(mypath)) //mypath is the path to the file
or if you want a indd file in a folder in a more generic way
you say
FIle.openDialog("Pick me","Files : *.indd", true);
hope it helps
Loic

PS : Hey folks, saying that I noticed on my mac that the filter seems to be ignored meanwhile on my pc at work it's taken in account ? Is that something normal ?
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
Participant ,
Aug 07, 2008 Aug 07, 2008
Loic,

Did you see my message a few back? It explains the differences between Mac and Windows filters and provides cross-platform code for handing it.

Dave
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
People's Champ ,
Aug 07, 2008 Aug 07, 2008
Hi Dave,
Sorry to make you post again. I read quickly you former post and it's true I should have been more attentive to it. Ok I got the idea now.
Thanks a lot for your post and precisions !
Loic
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
Guest
Aug 07, 2008 Aug 07, 2008
Hi Loic,

Sorry I have not made myself clear.

I should have mentioned that I am using openDlg on WIN JS CS2.

What I am hoping to achive is to multi-select files in a particular folder.

myFile=myDocs.openDlg("Select Files To Open", myFolder+"/"+myMask, true);

The aboove line works right upto displaying all require files in the particular folder but I cannot multi select.

Regards
Norbert
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
Participant ,
Aug 07, 2008 Aug 07, 2008
myFolder + "/" myMask

Does not look like the right syntax for a filter.

We've been trying to tell you that for a few messages now.

Dave
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
Guest
Aug 07, 2008 Aug 07, 2008
Hi Dave:

Re: We've been trying to tell you that for a few messages now.

I've seen yours and Loic post saying to use Files: *.indd as a filter

But like I mentioned filtering is not the issue.

Using myFolder+"/"+myMask, works perfectly in filtering the files that I need displayed (And what I am hoping to acvhive)

What I cannot manage to achieve is the select multiples files i.e: The third parameter in openDlg.

Thanks so much for responding.

Sincerely appreciate this.

Regards
Norbert
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
Guest
Aug 07, 2008 Aug 07, 2008
Hi Dave,

I just tried the code on CS3 and it allows me to select multiple files.

So I am guessing that the code does not work for CS2 to multi select.

However, in CS2's user interface when I do a File---> Open, it allows me to do a multi select.

Any suggestions?

Regards
Norbert
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
People's Champ ,
Aug 07, 2008 Aug 07, 2008
Have a look on page 540 of the Indesign CS2 scripting reference :
openDialog
File.openDialog
([prompt][,select])
prompt
Optional. A string containing the prompt text, if the dialog allows a prompt.
select
Optional. A file or files to be preselected when the dialog opens:
In Windows, a string containing a comma-separated list of file types with descriptive
text, to be displayed in the bottom of the dialog as a drop-down list from which the user can select which types of files to display.
Each element starts with the descriptive text, followed by a colon and the file search masks for this text, separated by semicolons. For example, to display two choices, one labeled Text Files that allows selection of text files with extensions .TXT and .DOC, and the other labeled All files that allows selection of all files:
Text Files:*.TXT;*.DOC,All files:*
So it seems CS2 won't set capacity to allow multiple selecting files
So you have to use a workaround.
Folder.getFiles() with a indd selection could do the trick but it implies that it will get ALL the files available and not the one the user may only want...
BUT you know what ? Why don't you just giv a try and maybe in CS2 multi opening will be allowed with the File.openDialog method without any need to set anything ?
For more precise informations, I give my place to specialists :-)
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
Guest
Aug 10, 2008 Aug 10, 2008
Hi Loic,

You are right. Page 540 of the CS2 scripting guide does say:

"A file or files to be preselected when the dialog opens:"

However myFile=File.openDialog("Pick me","Files : *.indd", true);

Doesn't aqllow multiple selections.

So is the CS2 Scripting guide wrong or am I doing something wrong?

Regards
Norbert
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
People's Champ ,
Aug 11, 2008 Aug 11, 2008
Well effectively the formulation of the explanation let think that you can select multiple files but the command doesn't.
Weird, either the explanation is false, either we misunderstood a point.
Olav will be welcome to clear that stuff !
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
Guest
Aug 11, 2008 Aug 11, 2008
How does one get in touch with Olav to rea a particlar thread? Or does he read all thats posted here??
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
People's Champ ,
Aug 12, 2008 Aug 12, 2008
okvern at adobe.com at the last resort :-)
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
Guest
Aug 12, 2008 Aug 12, 2008
Hi Loic,

I normally don't send private emails regarding forum posts but maybe this time I will.

However, what other options do I have before I email Olav?

Regards
Norbert
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
People's Champ ,
Aug 12, 2008 Aug 12, 2008
What about posting a new topic called "CS2 openDialog problem" ?
It's true that if Olav can answer to your problem, it's better that anyone can enjoy it.
Loic
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