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

loadin another script

Engaged ,
Jan 23, 2019 Jan 23, 2019

Hi.

Can I determine the location of the currently running script? I need the "filePath".

My intension:

The script is running and changes/makes things in InDesign. Then I want it to load another script from the same folder which one does its own work.

TOPICS
Scripting
793
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

correct answers 1 Correct answer

Community Expert , Jan 23, 2019 Jan 23, 2019

var path = new File($.fileName);

var filePath = path.parent

-Manan

Translate
Community Expert ,
Jan 23, 2019 Jan 23, 2019

Try $.fileName

-Manan

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
Engaged ,
Jan 23, 2019 Jan 23, 2019

That´s not bad. But I need only the path, without the name. Is that possible?

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
Community Expert ,
Jan 23, 2019 Jan 23, 2019

var path = new File($.fileName);

var filePath = path.parent

-Manan

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
Engaged ,
Jan 23, 2019 Jan 23, 2019

Thanks Manan.

I make it like:

        var thisScript = new File($.fileName);

        var thisScriptPath = thisScript.parent;

        var newScript = File(thisScriptPath + "/newFileName.jsx");

it´s perfect!

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
Engaged ,
Jan 23, 2019 Jan 23, 2019

I do it like this:

var globalScriptPath = getScriptPath().path;

function getScriptPath() {

try {

     return app.activeScript;

} catch(e) {

     return File(e.fileName);

}

}

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
Engaged ,
Jan 23, 2019 Jan 23, 2019
LATEST

Hey Stafan:

der sagt mit hierbei:

"Skript kann in Zielengine "main" nicht ausgeführt werden! (cannot execute in main-engine)

(#21) undefined is not an object"

...

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