Copy link to clipboard
Copied
Hello!
I have the following documents open in Photoshop:
123456_mrp_ou.tif
869548_mrp_ou.tif
896589_mrp_in.tif
896589_mrp_ou.tif
..and I have this if statement within a for loop to look for files with a specific "pid" number and save them in my Documents folder:
var originalPid = 896589
for(i = 0; i < app.documents.length ; i ++) {
activeDocument = app.documents
if(activeDocument.name.substring(0,6) === originalPid) {
var standardSave = new File('/Users/constantincerdan/Documents/' + activeDocument.name)
activeDocument.saveAs(standardSave, TiffSaveOptions, false, Extension.LOWERCASE)
}
}
This does not find the two files and save them when I run it. However, the for loop without the if statement runs just fine and saves all the documents into the Documents folder:
var originalPid = 896589
for(i = 0; i < app.documents.length ; i ++) {
activeDocument = app.documents
var standardSave = new File('/Users/constantincerdan/Documents/' + activeDocument.name)
activeDocument.saveAs(standardSave, TiffSaveOptions, false, Extension.LOWERCASE)
}
How do I get it to work with an if statement so that it only saves those two?
Any help is much appreciated!
You are comparing apples with oranges, you need to compare strings.
originalPid = 896589;
alert(typeof originalPid);
Copy link to clipboard
Copied
You are comparing apples with oranges, you need to compare strings.
originalPid = 896589;
alert(typeof originalPid);
Copy link to clipboard
Copied
Doh! How silly of me. I should have noticed this myself. Thank you, Philip.