Copy link to clipboard
Copied
How to create a warning text or icon for a particular name via Ps Script.
Eg: 2218146180.B08145Z6KV.PT11, 2218145977.B08145Z6KV.PT01, 2218102275.B09HX5L6YC.PT02
In the above names i need warning text or icon only for the images ending with .PT02.
Any Help would be a great solution for my problem 🙂
/PT02$/.test(activeDocument.name)
I would do something like this:
if (app.activeDocument.name.match(/\.PT02$/i)) {
app.beep();
alert("!");
}
Copy link to clipboard
Copied
/PT02$/.test(activeDocument.name)
Copy link to clipboard
Copied
I can spot the regex, but I couldn't get this to work?
Copy link to clipboard
Copied
It gives 'true' for image name ending with characters put to regexp, so what do you mean?
Copy link to clipboard
Copied
I mean that the code does nothing, is this just a snippet? If so, what further code should be added?
EDIT: OK, I have not used .test() before, so a little bit of a read and play gave me this:
if (/\.PT02$/i.test(activeDocument.name) === true) {
app.beep();
alert("!");
}
Copy link to clipboard
Copied
This is solution for user problem. How that is going to be used is up to him, so I don't provide beeps, alerts or anything else. He's going to use it his way. The point is to filter specific names.
Copy link to clipboard
Copied
Thanks for helping me 🙂
Copy link to clipboard
Copied
Does it solve your problem?
Copy link to clipboard
Copied
I would do something like this:
if (app.activeDocument.name.match(/\.PT02$/i)) {
app.beep();
alert("!");
}
Copy link to clipboard
Copied
Thanks for adding alert 🙂