New to ExtendScript and trying to finish an automation project for work.
I have a bunch of images that I am combining in photoshop via a script and need to open a image pairing based on an initial image. I know that the name of my paired file will be predictable up until the final character, at which point it will be any uppercase letter A-Z.
For example:
CH-14B1-SP-01-A can pairs with CH-14B1-SP-PV-01-A, but could also conceivably be paired with CH-14B1-SP-PV-01-B. Each paired file has an A-D replicate and we choose the best to be paired.
I have a script working that requires user input to decide what replicate to look for. I want to automate this. My code looks like this:
// ask user input for PV replicate letter
var repLetter =prompt("Which PV replicate would you like to use? (A.. B.. C.. etc.)");
// get the info out of the source doc
var fileName = srcDoc.name;
var docName = fileName.substring(0,fileName.length -4);
var filePath = srcDoc.path.toString();
var fileExt = fileName.substring(fileName.length -4, fileName.length);
var nameCheck = fileName.substring(0,fileName.indexOf("CH-14B1-SPI-"));
if (nameCheck <1)
{
var fileNum = fileName.substring(12,fileName.length -5) + repLetter;
// no underscore so we need to open it's namesake
// alert(nameCheck)
var filePair = filePath + "/PV/" + "CH-14B1-SPI-PV-" + fileNum + fileExt;
openThisFile(filePair)
Is there any way to make the var repLetter just accept any value at all?
Something like
var fileNum = fileName.substring(12,fileName.length -5) + [a-z];
I tried the above hoping it would do the trick (again very new to this) and I was told that "a" was undefined.
prompt("prompt", "defaultValue")) - CRGreen