1

Is it possible to run a run a Python script from a Photoshop script? For example: I've got two files: my_photoshop script.jsx which will run from Photoshop. And the seconds (python) my_python_script.py, which is called from with Photoshop by the first script.

my_photoshop script.jsx

// Call external file from Photoshop
call my_python_script.py; //pseudo code

my_python_script.py

# Python script
print ("Hello from Photoshop!")

I know it's possible to do something similar via a batch file...

my_photoshop script.jsx

// Call the external batch files
var myBat = new File("D:\\temp\\my_batch_file.bat");
alert(myBat);
myBat.execute();

my_batch_file.bat

echo Python...
"C:\path\to\python.exe" "c:\path\to\hello_world.py"
pause 100

However, but can it be done directly? Or is this as close as it's gonna get?

1 Answer 1

3

Using app.system:

my_script.jsx

app.system('python "D:/path/to/my_py.py" ' + app.version)

my_py.py:

import sys
file = open("D:/path/to/py.log", "w")
file.write("Hello from Photoshop!\n")
file.write("PS version: " + str(sys.argv[1]))
file.close()

Result of py.log:

Hello from Photoshop!
PS version: 20.0.10

p.s. note that File.execute() opens the file with a default app. If a user associated .bat files with a text editor, running myBat.execute() will open the file in the text editor.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.