If Path named "" exists

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

trondwa
Posts: 1
Joined: Mon Sep 12, 2016 11:08 am

If Path named "" exists

Post by trondwa »

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

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

User avatar
txuku
Posts: 136
Joined: Thu Jan 01, 1970 12:00 am

Re: If Path named "" exists

Post by txuku »

Bonjour

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");
}
}
pixxxelschubser
Posts: 26
Joined: Mon Aug 01, 2016 8:59 pm

Re: If Path named "" exists

Post by pixxxelschubser »

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
}