Koenraad Van Doorslaer, PhD

The Jagger Principle

14 Mar 2016

Batch remove clipping masks from illustrator file I often find myself editing figures from other sources in Illustrator. Usually, importing third party files into Illustrator creates hundreds of "clipping masks" that need to be removed in order to edit the file. This used to take me a lot of "right click - remove clipping mask" steps. Anyway, I recently came across this really cool piece of code (source).

 #target Illustrator  
 // script.name = RemoveClippingMasks.jsx 
 // script.description = deletes all PageItems being used as clipping masks.  
 // script.parent = Kenneth Webb // 01/07/2013  
 // script.elegant = true?  
 var docRef = app.activeDocument;  
 var clippingCount = 0  
 clipScan()  
 //loops through all pageItems, removing those that are clipping masks  
 function clipScan () {  
   for (i=docRef.pageItems.length-1;i>=0;i--) {   
     if (docRef.pageItems[i].clipping == true){  
       docRef.pageItems[i].remove();  
       clippingCount++;  
     }  
   }  
 };  
 alert ("All "+clippingCount+" Clipping Masks Removed") 

Just copy the above code, paste into your favorite text editor, and save using the extension ".jsx". In illustrator, open the file you want to edit, click on File → Scripts → Other Script, and sit back. Depending on how many clipping masks you have this may take a while, so be patient!