Hi, I have quite a big workflow going with photoshop actions doing selective adjustments on files based on paths. However I run into problems when the path with the specific name does not exist. Is it possible to make a script looking for the existence of a path named "stone" and then execute an action if the condition is met, if not, do nothing?
Any help would be greatly appreciated!
Trond
If Path named "" exists
Re: If Path named "" exists
Bonjour
You can use the " try catch " method !
This by exemple
You can use the " try catch " method !
This by exemple
Code: Select all
var x=prompt("Enter a number between 0 and 10:","");
try
{
if(x>10)
{
throw "Err1";
}
else if(x<0)
{
throw "Err2";
}
else if(isNaN(x))
{
throw "Err3";
}
}
catch(er)
{
if(er=="Err1")
{
alert("Error! The value is too high");
}
if(er=="Err2")
{
alert("Error! The value is too low");
}
if(er=="Err3")
{
alert("Error! The value is not a number");
}
}
-
- Posts: 26
- Joined: Mon Aug 01, 2016 8:59 pm
Re: If Path named "" exists
Try this:
Code: Select all
try {
var aDoc = app.activeDocument;
var allPathItems = aDoc.pathItems;
var aPath = aDoc.pathItems.getByName("stone");
// alert('The pathItem: '+aPath.name+' was found');
// do whatever you want
} catch(e) {
// alert(e.message+': '+e.line);
// do nothing
}