0

I have a problem with Indesign. I have a document, where I want to add a picture programmatically. This is easy, when I use a picture on my localdrive. But I want to add a picture from a server path like \myserver\pictures\pic.jpg

I tried it like I add a picture from localdrive

var f = new File("\\myserver\pictures\pic.jpg");
imgPicture.place(f, false);

Then the value in f is

//myserver/pictures/pic.jpg 

I build a try catch around it. The errorMessage is undefined. I get the same error, when i use the networkdrive letter, like

/x/pictures/pic.jpg

As i saw in the documentation for the file-object, there is only one string-parameter for the path.

Is there a solution? On an other forum, I found a thread where someone had the same problem. But he did a dirty way to solved it. He did a fileOpenDialog and pasted the link to the file and then it downloads the file to the temp directory.

I can't do this, because I have on my server about 100,000 pictures.

Thanks for help.

Micha
  • 3
  • 2

2 Answers2

1

Another issue of yours may be that backslash may be interpreted as escaping character thus resulting in something like : \myserverpicturespic.jpg" So you may need to escape the escaping character like : "\\myserver\pictures\pic.jpg" and then pass this string. Finally, when I have a doubt about a file path, I usually use this bit of code :

var f = File.openDialog();
if ( f ) $.writeln ( f.fsName );

FWIW

Loic

Loic
  • 2,173
  • 10
  • 13
  • 1
    I solved it by myself. Our DNS had a issue with the name, so I took the IP and *tada* it works String is now: \\192.168.20.24\pictures\pic.jpg And I forgotten to check if the file exists. Thanks for the response. – Micha Sep 03 '15 at 06:04
0

I can not get the value of f with the forward slashes as you do. I tried your code and it works fine for me if I pass the file-path as

var f = new File("//myserver/pictures/pic.jpg");

You could convert you path with .toString().replace(/\/g, '/')

Also try to replace spaces in the filepath with  

CS 5.5 OSX 10.9

Nicolai Kant
  • 1,391
  • 1
  • 9
  • 23