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

Trying to run a python script from extend script

Explorer ,
Sep 25, 2018 Sep 25, 2018

Hello,

I'm currently working on an illustrator script in which i need to run a separate python script with parameters.

I'm creating a .bat file in the same folder as the .py script, if i double click this bat file it runs the python script as normal, but if the jsx tries to execute it, it sais it cannot find the .py file.

Here is me code:

var scriptFile = new File($.fileName);

var scriptPath = scriptFile.parent; // leads to /c/projects/TechArt/adobe/illustrator/Illustrator_preview_script

var myScriptPath = File(app.activeScript);

var myScriptName = myScriptPath.fullName; // Leads to /c/Program Files/Adobe/Adobe Illustrator CC 2017/Support Files/Content/Windows/tmp000000001

var os = $.os;

if (os.indexOf("Windows") >=0)

{

  var batPath = scriptPath + "/runPyScript.bat";

  var runFile = File(batPath);

  if (!runFile.exists)

  {

    runFile = new File(batPath); // Create the bat file

  }

  runFile.encoding = "UTF-8";

  runFile.lineFeed = "Windows";

  runFile.open("w");

  runFile.write("python thumbnail_shortcut_illustrator.py " + folderPath + "\npause"); // write to the bat file

  runFile.close();

  runFile.execute(); // execute the bat file

This is the result if i run the .jsx script:

CantRunt.jpg

And this is the result if i double click the bat file:

CanRun.jpg

Am confusion

TOPICS
Scripting
2.3K
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
Adobe
People's Champ ,
Oct 23, 2018 Oct 23, 2018
LATEST

It may be an environment variable issue meaning that when the bat file is executed it has no clue of the current directory and eventually not finding the py file.

Try passing the full path in the bat file :

runFile.write("C:\\projects\\TechArt\\adobe\\illustrator\\Illustrator_preview_script\\python thumbnail_shortcut_illustrator.py " + folderPath + "\npause"); // write to the bat file

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