Running an external program and waiting for completion

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

psykojello

Running an external program and waiting for completion

Post by psykojello »

I apologize if this has already been answered, but I could not find it in my searches:

I'm trying to run an external program (in this case a python script) from my photoshop javascript.

I figured out that I can use the File.execute() function to run an program but can I get Photoshop to wait for it to finish execution before continuing to the next line?

If that isn't possible, can I make a delay statement to wait 1 or 2 seconds before continuing?

Thanks in advance!

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Paul MR

Running an external program and waiting for completion

Post by Paul MR »

One way would be to use a flag file and get your Python script to remove the file at the end of it's process. IE.

Code: Select allvar pythonScript = File(Folder.desktop + "/myPython.py");
var pyFlag = File(Folder.desktop + "/Python Flag");
pyFlag.open('w');
pyFlag.close();
pythonScript.execute();
while(true){if(!pyFlag.exists) break;}
$.writeln("Python script completed ");