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

ExtendScript: how to find user's home directory

Contributor ,
Aug 24, 2020 Aug 24, 2020

Copy link to clipboard

Copied

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.

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

correct answers 1 Correct answer

Enthusiast , Aug 25, 2020 Aug 25, 2020

This is how I would find the path:

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

Votes

Translate

Translate
Community Expert ,
Aug 24, 2020 Aug 24, 2020

Copy link to clipboard

Copied

In your script, you can use

app.UserSettingsDir

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

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
Contributor ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

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).

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 ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

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. 

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
Contributor ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

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

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 ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

This is how I would find the path:

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

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
Contributor ,
Aug 25, 2020 Aug 25, 2020

Copy link to clipboard

Copied

LATEST

Indeed, this is the shortest and most elegant way of doing it. Thank you!

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