I am frequently in a situation where, after finishing work on multiple open photoshop documents, I want to play a specific action on a few of them. The document names ALWAYS match a pattern that should be pretty easy to match with regex. Essentially:
-If the document name is 5 or 6 digits + "F", play action A.
-If the document name is 5 or 6 digits + "FX", play action B.
-If the document name is 5 or 6 digits + "B", play action A.
-If the document name is 5 or 6 digits + "BX", play action B.
I gather that getByName only works with exact string matches, so in order to use regex I will need a for loop to look through every open doc, check for a regex .match, then play the correct action. But I am having trouble achieving the desired result.
p.s. the targeted documents have never been saved and therefor have no extensions, so the regex pattern DOES NOT need to account for this.
Thanks!
2
Answers
I take it your after the regex?
Try
It seems like
RegExp
in JavaScript for photoshop didn’t implemented thed
. So I successfully used[0-9]
instead.In case of a match the result will be two times the file name as an array. A mismatch will be
null
.