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

Want to Open File from the Path

Enthusiast ,
Nov 23, 2012 Nov 23, 2012

Copy link to clipboard

Copied

Hello,

I am new to Indesing Scripting. Studying through "InDesignCS3_ScriptingGuide_JS" (page no 12).

I am using Mas OS.

My file saved in Desktop in the name "aa.indd". It open correctly.

Running Sucessfully below code:

var myOpen = app.open(File("~/Desktop/aa.indd"));

But if i saved my file in "Macintosh HD/Users/Shared/TEST/aa.indd" or some other path it not open properly.

Failure code is:

var myOpen1 = app.open(File("Users/Shared/TEST/aa.indd)

Please find the attachment.

Kindly let me know in case of any clarification.

Screen Shot 2012-11-23 at 7.24.35 PM.png

Thanks in advance

BEGINNER

TOPICS
Scripting

Views

1.2K

Translate

Translate

Report

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
Advisor ,
Nov 23, 2012 Nov 23, 2012

Copy link to clipboard

Copied

var myOpen1 = app.open(File("Users/Shared/TEST/aa.indd"));

maby that is your problem?

Votes

Translate

Translate

Report

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
Guide ,
Nov 23, 2012 Nov 23, 2012

Copy link to clipboard

Copied

I think you might also need.

~/user.........

P.

Votes

Translate

Translate

Report

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
Community Expert ,
Nov 23, 2012 Nov 23, 2012

Copy link to clipboard

Copied

Your path is not correct. It's not what Pickory says, because your "Users" folder is not somewhere inside your local folder (which is indicated by the tilde). To use an absolute path, you have to start with a root folder:

/Users/Shared/TEST/aa.indd

.. This assumes the root folder of your Mac is called plain '/'. Can't test right now; it depends on your OS X version (? perhaps on local settings? time of day?), perhaps you have to start with /Volumes, or possibly with /siraj's\ Mac\ mini

Anyway, it's the path that you supply that is wrong, and you should use the right one.

Votes

Translate

Translate

Report

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
Community Expert ,
Nov 23, 2012 Nov 23, 2012

Copy link to clipboard

Copied

A-ha, you don't even need to know the root path. This also works on Windows(!):

path = '~/../All Users';

alert (Folder(path).getFiles().join('\r'));

i.e., the '~' directs you to your own root folder, and with '..' you navigate one 'level' up (so you are in the "Users" folder) and you can go down again into any other's Users folder.

So you could try this instead:

var myOpen1 = app.open(File("~/../Shared/TEST/aa.indd"));

Votes

Translate

Translate

Report

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
Enthusiast ,
Nov 23, 2012 Nov 23, 2012

Copy link to clipboard

Copied

Hi Jongware and All,

It working fine.

Thanks a lot!!!

But i placed a file in different path(Application folder).

It not works

//var myOpen1 = app.open(File("~/Applications/TEST/aa.indd"));

//var myOpen1 = app.open(File("~/../Applications/TEST/aa.indd"));

//var myOpen1 = app.open(File("Macintosh HD/Applications/TEST/aa.indd"));

Votes

Translate

Translate

Report

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 ,
Nov 25, 2012 Nov 25, 2012

Copy link to clipboard

Copied

LATEST

Your first one actually does work but you have placed your test… in the system level applications folder…

// This one points to your current user account applications folder

// This is valid you just didn't put the file there…

var myOpen1 = app.open( File( "~/Applications/TEST/aa.indd" ) );

// This one points to your main system level applications folder

// These are apps available to all user accounts…

var myOpen1 = app.open( File( "/Applications/TEST/aa.indd" ) );

Votes

Translate

Translate

Report

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