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

.remove() not removing the object

Community Beginner ,
Aug 05, 2021 Aug 05, 2021

He y'all! 
I have a script going that opens up files from a folder I selected, and trying to target a specific sub layer within the file to be deleted. 
Here is the file structure:

Screenshot 2021-08-05 155408.jpg

I'm trying to target that image but when I run the script I get an error "No Such Element"
I'm scratching my head at the object model and have been at this for 2 hrs now. Any help understanding this would definitely be appreciate! 
My code:

 

#target "Illustrator";
var myFolder = Folder.selectDialog (prompt);
var myFiles = myFolder.getFiles("*");
for(i=0; i<myFiles.length;i++){
    var myDoc = app.open(myFiles[i]);
    try{
        myDoc.layers.getByName("Layer 1").layers.getByName("<Clip Group>").pageItems.getByName("<Image>").remove();
        myDoc.close (SaveOptions.SAVECHANGES);
        } catch(e){
            alert(e);
            //myDoc.close(SaveOptions.DONOTSAVECHANGES);
            }
        }

 

 

TOPICS
Scripting
143
Translate
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
Adobe
Guide ,
Aug 05, 2021 Aug 05, 2021
LATEST
Translate
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