Copy link to clipboard
Copied
Hi,
A while ago I was given this perfect script from @Stephen Marsh
(Thanks again Stephen!)
It works great!
The script is designed to preform multiple (previously saved/recorded) image adjustedment processes in Photoshop. Until all the images in the designated folder are adjusted, after which the script stops.
Now I thought of a new addition to this proces, that is maybe possible:
This is because I like to render my files and have them image-adjusted in PS after that in one flow.
1. Is it possible to have the script read the folder and 'wait' for a new render image to appear? (wait time manually adjustable)
2. When this wait-time is exceeded, this probably caused by the render proces to have ended, hence no more new images. At this stage the script could shutdown pc.
I hope this is in anyway feasible.
Regards AC
1 Correct answer
On the Mac, call the following AppleScript code to shut down the computer:
tell application "System Events"
shut down
end tell
On Windows, use the following code in your script:
app.system("shutdown /s");
Explore related tutorials & articles
Copy link to clipboard
Copied
1) An ExtendScript code runs until completion, which ties up Photoshop. So I don’t believe that we can have the Photoshop script “wait” for new images, unless the script repeated the operation to get files multiple times. Unless the script removed the files from the source folder, they would need to be logged and compared.
So all things considered from my limited understanding of how things work, this isn’t possible.
What is possible is that another app running in the background, such as Adobe Bridge can have a “watched/hot folder” script running and then pass things over to Photoshop, however, I believe that it too would have the same constraints with synchronous code execution.
So it may be possible, but I’m leaning towards the too hard (for me to do) side.
2) I don’t believe that quitting running apps and or shutting down the computer is supported via ExtendScript. The ExtendScript would have to call an operating system command to do so.
So it may be possible, so again I’m leaning towards the too hard (for me to do) side.
I’m happy for those with more knowledge and experience to say otherwise and offer code examples though!
Copy link to clipboard
Copied
I fully understand Stephen, thank you for your quick reply!
If someone knows code on how to do part 2 only: shut down pc when a script is finished? That would be helpfull.
Copy link to clipboard
Copied
@Stephen Marsh is correct that a script has to run its course and can't wait for input that you want. While probably not exactly what you want, I had a work script that would format my images, but if I opened new images through Bridge directly into Camera Raw, my script would keep running. That saved me a lot of time. As far as what Stephen mentioned about logging the files and stopping, that can be done, and I did do something along those lines. Basically a folder of images would be selected and then a counter and log could be saves to a support file that the main scripts reads upon startup and then continues, where left off.
Copy link to clipboard
Copied
thank you for your time and info.
I was hoping for a "wait for for files solution" and pc shutdown option.
How I imagened it:
I thought it be posssibe to put the core task (image processing) script inside a loop. This loop checks if there are new files to proces. At end of loop it has a counter how manny times the loop has been run, with a wait delay following of 10 minutes. So with this couter info you could start an action, lets say counter = 3, pc shuts down. So when it has not had files to proces for 30 minutes, pc shuts down.
Copy link to clipboard
Copied
A script can be paused, however, Photoshop will not be able to do anything else until the pause finishes and the script has finished executing:
$.sleep(2000); // milliseconds
I looked into a Windows batch script and PowerShell script to shut down, without success.
Copy link to clipboard
Copied
Thank you Stephen for your effort. I see, the bottleneck is therefore PS, not the script, I understand. Then I keep using the script for running after all renders are finished.
Copy link to clipboard
Copied
On the Mac, call the following AppleScript code to shut down the computer:
tell application "System Events"
shut down
end tell
On Windows, use the following code in your script:
app.system("shutdown /s");
Copy link to clipboard
Copied
ah great, I will use this in my script. Thank you!

