Skip to main content
hadih26673991
Inspiring
Aug 24, 2020 1:17 PM UTC
Answered

ExtendScript: how to find user's home directory

I am new to Adobe ExtendScript, I would like to know how I can replace the tilde (~) with the absolute path of user's home directory?

 

In my script, I need to find the absolute path of the script itself. To do this, I use: var scriptPath = File($.fileName).path

But this gives me a tilde for the first part which is not recognized by the FrameMaker as user's home directory; therefore, I cannot use it to pinpoint where my files are located.

This topic is closed to new replies. Start a new post to keep the conversation going.
Ian Proudfoot
Ian ProudfootCorrect answer
Legend
Aug 25, 2020 11:19 AM UTC

This is how I would find the path:

var scriptPath = Folder(File($.fileName).path).fsName;

6 replies

Ian Proudfoot
Legend
Aug 25, 2020 9:56 AM UTC

The quick way to get the full path from an ExtendScript file object (in a way that FrameMaker can digest) is as follows:

var scriptPath = File($.fileName).fsName;

fsName provides the platform-specific full path name for the referenced file. 

Translate
hadih26673991
Inspiring
Aug 25, 2020 10:53 AM UTC

Awseome. Then I would only need to remove the filename itself to get the path.

Translate
Ian Proudfoot
Ian ProudfootCorrect answer
Legend
Aug 25, 2020 11:19 AM UTC

This is how I would find the path:

var scriptPath = Folder(File($.fileName).path).fsName;
Translate
frameexpert
Community Expert
Community Expert
Aug 24, 2020 4:16 PM UTC

In your script, you can use

app.UserSettingsDir

to give you the 15 folder (for FrameMaker 2019), etc. Does this help?

Translate
www.frameexpert.com
hadih26673991
Inspiring
Aug 25, 2020 7:26 AM UTC

Hi Rick,

Thanks. Yes that helped. I was able to extract the user's home directory out of the home directory of FrameMaker folder 16 (in my case).

Translate