• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Cannot execute script in target engine 'main'! (#45) Object is invalid

Community Beginner ,
Feb 16, 2022 Feb 16, 2022

Copy link to clipboard

Copied

Hey all I'm running into a ESTK error when running my script. The script will run a file, make it's checks and move on to the next file. It'll do this for a couple until it reaches a certain template and give me the error stated in the Subject Line. Any help would be greatly appreciated! 

 

Goal: The goal of this script is to check a files text layers to see if the ALL CAPS setting is turned on and doesn't already exist for any layer, if true "<RT_f>" gets added to the layer name. If false, the file is meant to be closed and jump back into the for loop for the next file. 

 

A couple things I need to adjust that I'm aware of are when the script opens the file and this prompt pops up

Joshua22968067jz1j_0-1645056055031.png


I still need to figure out how to always apply the "Keep Layers" option (if anyone know I would be forever thankful)  

I will attach a couple files that will run fine against this script and a few that produce the Subject Line error. 

Script:

//#target Photoshop
var files = Folder('/c/temps/psd').getFiles(/.psd$/i)
for (var i = 0; i < files.length; i++) {
  var fileRef = files[i]
  var docRef = app.open(fileRef)
  var ifChanges = false
  $.writeln(fileRef)
  try {
    for (var a = 0; a < docRef.layers.length; a++) {
      var curLayer = docRef.layers[a]
      try {
        if (
          curLayer.kind == LayerKind.TEXT &&
          curLayer.textItem.capitalization == TextCase.ALLCAPS &&
          curLayer.name.indexOf('<RT_f>') == -1
        ) {
          curLayer.name = '<RT_f>' + curLayer.name
          ifChanges = true
        }
      } catch (e) {
        docRef.close(SaveOptions.DONOTSAVECHANGES);
        continue;
      }
    }
  if (ifChanges) {
    $.writeln(fileRef.Name)
    docRef.save();
  }

  docRef.close();
  } catch (e) {
    docRef.close(SaveOptions.DONOTSAVECHANGES);
    continue;
  }


}

 
Console Log:

/c/temps/psd/BCBH-002-3RL001.psd
/c/temps/psd/BCBH-002-3RL002.psd
/c/temps/psd/BCBH-002-3RL003.psd
/c/temps/psd/BCBH-04509-3S001.psd
/c/temps/psd/BCBH-0T221-C0001.psd
/c/temps/psd/BCBH-BG200-00009-3A001.psd
/c/temps/psd/BCBH-BG200-00009-3A002.psd
/c/temps/psd/BCBH-BG200-00009-3A003.psd
/c/temps/psd/BCBH-BG200-00009-3A004.psd
/c/temps/psd/BCBH-BK00125-3A001.psd
/c/temps/psd/BCBH-BK00125-3A002.psd
/c/temps/psd/BCBH-BK00125-3A003.psd
/c/temps/psd/BCBH-BK00166-A001.psd
/c/temps/psd/BCBH-BK00166-A002.psd
/c/temps/psd/BCBH-BK00166-A003.psd
/c/temps/psd/BCBH-BK00299-3B001.psd
/c/temps/psd/BCBH-BK100-00142-3C001.psd
/c/temps/psd/BCBH-BK100-00142-3C002.psd
/c/temps/psd/BCBH-BK100-00142-3CR001.psd
/c/temps/psd/BCBH-BK500-10459-3A001.psd
/c/temps/psd/BCBH-CB30016-3C020.psd
/c/temps/psd/BCBH-CB500-30029-3A001.psd
/c/temps/psd/BCBH-ER160-00000-3A001.psd
/c/temps/psd/BCBH-ER160-00000-3A002.psd
/c/temps/psd/BCBH-ER160-00000-3A003.psd
/c/temps/psd/BCBH-ER160-00000-3A004.psd
/c/temps/psd/BCBH-ER160-00000-3A005.psd
/c/temps/psd/BCBH-ER160-00000-3A006.psd
/c/temps/psd/BCBH-ER160-00000-3A007.psd
/c/temps/psd/BCBH-ER160-00000-3A008.psd
/c/temps/psd/BCBH-ER160-00000-3A009.psd
/c/temps/psd/BCBH-ER160-00000-3A010.psd
/c/temps/psd/BCBH-EX338-00000-3K001.psd
/c/temps/psd/BCBH-EX510-00000-003-3EX001.psd
/c/temps/psd/BCBH-EX510-00000-003-3EX002.psd
/c/temps/psd/BCBH-EX510-00000-003-3EX003.psd
/c/temps/psd/BCBH-EX510-00000-003-3EX004.psd
/c/temps/psd/BCBH-EX510-00000-003-3EX005.psd
/c/temps/psd/BCBH-EX510-00000-003-3EX006.psd
/c/temps/psd/BCBH-EX510-00000-003-3EX007.psd
/c/temps/psd/BCBH-EX510-00000-003-3EX008.psd
/c/temps/psd/BCBH-EX510-10099-3EX001.psd
/c/temps/psd/BCBH-EX510-10099-3EX002.psd
/c/temps/psd/BCBH-EX510-10099-3EX003.psd
undefined
/c/temps/psd/BCBH-EX510-10099-3EX004.psd
undefined
/c/temps/psd/BCBH-EX510-10099-3EX005.psd
/c/temps/psd/BCBH-J1-555-20025-3JP001.psd
/c/temps/psd/BCBH-J1555-002-3J001.psd
/c/temps/psd/BCBH-J1555-002-3J002.psd
/c/temps/psd/BCBH-J1555-20021-002-3J001.psd
/c/temps/psd/BCBH-KW10224-3K001.psd

The console log was added to help me identify which file the error was populating for (file will be included) and to hopefully get an answer as to why some files returned 'undefined' (but I'm not too worried about this one. 

 

That being said I have already googled that error and nothing has popped up. The only solution I have tried is to simply delete that file BUT there are multiple files that populate the error message from the Subject Line. 
In the files provided 'BCBH-KW10224-3K001.psd' is a sample file that will bring up this error in ESTK

I have to run this against 18k files so any help and/or solutions would be incredibly appreciated.

TOPICS
Actions and scripting , Windows

Views

121

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Adobe