Has anybody got a copy of this script or a similar version?
Wanting to run an action based on the filename
siva conditional
- Stephen_A_Marsh
- Posts: 38
- Joined: Sun Aug 04, 2019 12:37 pm
Re: siva conditional
That's pretty easy without Siva's script, without any GUI:
A GUI is easy enough to add either using a simple filename prompt() or even scriptUI. Scripting the GUI selection of the action set and action is obviously harder.
I'll dig up the code on the script that you are asking for as I have it in an archive.
Code: Select all
if (app.activeDocument.name == "Untitled-1") {
app.doAction("Action 1", "Action Set 1");
} else {
//app.doAction("Action 1", "Action Set 2");
}
I'll dig up the code on the script that you are asking for as I have it in an archive.
Last edited by Stephen_A_Marsh on Sat Jul 06, 2024 2:11 am, edited 1 time in total.
- Stephen_A_Marsh
- Posts: 38
- Joined: Sun Aug 04, 2019 12:37 pm
Re: siva conditional
- Attachments
-
- Siva's Photoshop Conditional Action.zip
- (9.07 KiB) Downloaded 484 times
-
- Posts: 1
- Joined: Wed Feb 05, 2025 3:40 am
- Location: https://geometrydashlitepc.io
Re: siva conditional
Your script is mostly correct but can be expanded for flexibility. Here’s an improved version with a GUI prompt using prompt() to allow user input and more structured logic:
Filename-Based Action Trigger in Photoshop (ExtendScript)
The script checks the document name and runs "Action 1" from "Action Set 1" if the file is "Untitled-1".
Otherwise, it prompts the user to enter an action set name and executes "Action 1" from the chosen set.
Filename-Based Action Trigger in Photoshop (ExtendScript)
Code: Select all
var doc = app.activeDocument; // Get the active document
var fileName = doc.name; // Get the document's filename
// Check if the filename matches a condition
if (fileName == "Untitled-1") {
app.doAction("Action 1", "Action Set 1");
} else {
var userInput = prompt("Enter action set name:", "Action Set 2");
if (userInput) {
app.doAction("Action 1", userInput);
}
}
Otherwise, it prompts the user to enter an action set name and executes "Action 1" from the chosen set.